diff --git a/config/install/jw_player.settings.yml b/config/install/jw_player.settings.yml index 4dc13c5..1dee974 100644 --- a/config/install/jw_player.settings.yml +++ b/config/install/jw_player.settings.yml @@ -1,3 +1,2 @@ jw_player_key: null -jw_player_key_7: null -jw_player_version: 6 \ No newline at end of file +jw_player_version: 6 diff --git a/config/schema/jw_player.schema.yml b/config/schema/jw_player.schema.yml index e7c9faa..321bf09 100644 --- a/config/schema/jw_player.schema.yml +++ b/config/schema/jw_player.schema.yml @@ -57,15 +57,12 @@ field.formatter.settings.jwplayer_formatter: jw_player.settings: type: config_object mapping: - jw_player_cloud_player_default: + cloud_player_library_url: type: string label: 'Cloud-Hosted Account Token' jw_player_key: type: string label: 'Self-Hosted Player License Key' - jw_player_key_7: - type: string - label: 'Self-Hosted Player 7 License Key' jw_player_version: type: integer label: 'Jw player version' diff --git a/jw_player.install b/jw_player.install index 37e1f49..44b1d88 100755 --- a/jw_player.install +++ b/jw_player.install @@ -44,4 +44,5 @@ function jw_player_update_8001() { } $config->set('jw_player_version', 6); drupal_set_message(t('JW Player version has been set to 6.')); + $config->save(); } diff --git a/jw_player.module b/jw_player.module index 240c272..ee54f9b 100755 --- a/jw_player.module +++ b/jw_player.module @@ -76,7 +76,7 @@ function template_preprocess_jw_player(&$variables) { } // Don't apply preset config in case of cloud hosted players. - if (!empty($config->get('jw_player_cloud_player_default'))) { + if (!empty($config->get('cloud_player_library_url'))) { // Copy player variables into their own array to be set as JavaScript // configuration. // @todo Bad smell here. Refactoring needed. @@ -153,7 +153,7 @@ function jw_player_default_settings() { ), ); - if ($config->get('jw_player_cloud_player_default')) { + if ($config->get('cloud_player_library_url')) { unset($defaults['base']); } } @@ -246,7 +246,7 @@ function jw_player_library_info_alter(&$libraries, $extension) { ); $config = \Drupal::config('jw_player.settings'); - if ($cloud_hosted_default = $config->get('jw_player_cloud_player_default')) { + if ($cloud_hosted_default = $config->get('cloud_player_library_url')) { // Cloud hosted player, use external JavaScript. $libraries['jwplayer']['js'][$cloud_hosted_default] = array( 'type' => 'external', @@ -306,5 +306,5 @@ function jw_player_use_legacy() { */ function jw_player_get_key() { $config = \Drupal::config('jw_player.settings'); - return jw_player_use_legacy() ? $config->get('jw_player_key') : $config->get('jw_player_key_7'); + return $config->get('jw_player_key') ? $config->get('jw_player_key') : NULL; } \ No newline at end of file diff --git a/src/Form/JwplayerSettingsForm.php b/src/Form/JwplayerSettingsForm.php index 51da0f5..fcd94a1 100644 --- a/src/Form/JwplayerSettingsForm.php +++ b/src/Form/JwplayerSettingsForm.php @@ -52,40 +52,20 @@ class JwplayerSettingsForm extends ConfigFormBase { $form['jw_player_key'] = array( '#type' => 'textfield', - '#title' => $this->t('Self-Hosted Player License Key (version 6.x)'), + '#title' => $this->t('Self-Hosted Player License Key'), '#description' => $this->t('Enter your key here. You can retrieve your license key from your downloads page at jwplayer.com.', array( '@url' => $url, )), '#default_value' => $config->get('jw_player_key'), - '#states' => array( - 'visible' => array( - array('select[name="jw_player_version"]' => array('value' => '5')), - array('select[name="jw_player_version"]' => array('value' => '6')), - ), - ), ); - $form['jw_player_key_7'] = array( + $form['cloud_player_library_url'] = array( '#type' => 'textfield', - '#title' => $this->t('Self-Hosted Player License Key (version 7.x)'), - '#description' => $this->t('Enter your key here. You can retrieve your license key from your downloads page at jwplayer.com.', array( - '@url' => $url, - )), - '#default_value' => $config->get('jw_player_key_7'), - '#states' => array( - 'visible' => array( - 'select[name="jw_player_version"]' => array('value' => '7'), - ), - ), - ); - - $form['jw_player_cloud_player_default'] = array( - '#type' => 'textfield', - '#title' => $this->t('Url of the Default Cloud-Hosted Player'), + '#title' => $this->t('Cloud Player Library Url'), '#description' => $this->t('You can get the url for your cloud hosted player at your downloads page at jwplayer.com. After choosing your player, simply copy and enter the whole url from the field "Cloud Player Library Url" here. If you are using the cloud hosted player, the self hosted files will not be loaded.', array( '@url' => $url, )), - '#default_value' => $config->get('jw_player_cloud_player_default'), + '#default_value' => $config->get('cloud_player_library_url'), ); return parent::buildForm($form, $form_state); @@ -97,9 +77,8 @@ class JwplayerSettingsForm extends ConfigFormBase { parent::submitForm($form, $form_state); $config = $this->config('jw_player.settings'); $config->set('jw_player_version', $form_state->getValue('jw_player_version')); - $config->set('jw_player_cloud_player_default', $form_state->getValue('jw_player_cloud_player_default')); + $config->set('cloud_player_library_url', $form_state->getValue('cloud_player_library_url')); $config->set('jw_player_key', $form_state->getValue('jw_player_key')); - $config->set('jw_player_key_7', $form_state->getValue('jw_player_key_7')); $config->save(); } diff --git a/src/Tests/JwPlayer7ConfigurationTest.php b/src/Tests/JwPlayer7ConfigurationTest.php index 96bddd7..f57315a 100644 --- a/src/Tests/JwPlayer7ConfigurationTest.php +++ b/src/Tests/JwPlayer7ConfigurationTest.php @@ -64,7 +64,7 @@ class JwPlayer7ConfigurationTest extends WebTestBase { // Add a random "Cloud-Hosted Account Token". $edit = [ - 'jw_player_cloud_player_default' => $token = 'https://content.jwplatform.com/libraries/' . $this->randomMachineName(8) . '.js', + 'cloud_player_library_url' => $token = 'https://content.jwplatform.com/libraries/' . $this->randomMachineName(8) . '.js', 'jw_player_version' => 7, ]; $this->drupalPostForm('admin/config/media/jw_player/settings', $edit, t('Save configuration')); @@ -86,6 +86,7 @@ class JwPlayer7ConfigurationTest extends WebTestBase { $this->assertFieldByName('label', 'Test preset'); $this->assertFieldByName('description', 'Test preset description'); $this->assertNoField('settings[mode]'); + $this->assertNoField('settings[skin]'); $this->assertFieldByName('settings[advertising][client]', 'vast'); $this->assertFieldByName('settings[advertising][tag]', 'www.example.com/vast'); $this->assertFieldByName('settings[controlbar]', 'bottom'); diff --git a/src/Tests/JwPlayerConfigurationTest.php b/src/Tests/JwPlayerConfigurationTest.php index 7468bcd..b111679 100644 --- a/src/Tests/JwPlayerConfigurationTest.php +++ b/src/Tests/JwPlayerConfigurationTest.php @@ -64,7 +64,7 @@ class JwPlayerConfigurationTest extends WebTestBase { // Add a random "Cloud-Hosted Account Token". $edit = [ - 'jw_player_cloud_player_default' => $token = 'https://content.jwplatform.com/libraries/' . $this->randomMachineName(8) . '.js', + 'cloud_player_library_url' => $token = 'https://content.jwplatform.com/libraries/' . $this->randomMachineName(8) . '.js', ]; $this->drupalPostForm('admin/config/media/jw_player/settings', $edit, t('Save configuration')); // Create a jw player preset.