diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php index 4d67770..b57885c 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/SettingsForm.php @@ -64,8 +64,6 @@ class SettingsForm extends SystemConfigFormBase { * * @param \Drupal\Core\Config\ConfigFactory $config_factory * The factory for configuration objects. - * @param \Drupal\Core\StringTranslation\TranslationManager $string_translation - * The string translation service. * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $fetcher_manager * The aggregator fetcher plugin manager. * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $parser_manager @@ -73,9 +71,8 @@ class SettingsForm extends SystemConfigFormBase { * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $processor_manager * The aggregator processor plugin manager. */ - public function __construct(ConfigFactory $config_factory, TranslationManager $string_translation, AggregatorPluginManager $fetcher_manager, AggregatorPluginManager $parser_manager, AggregatorPluginManager $processor_manager) { + public function __construct(ConfigFactory $config_factory, AggregatorPluginManager $fetcher_manager, AggregatorPluginManager $parser_manager, AggregatorPluginManager $processor_manager) { $this->configFactory = $config_factory; - $this->translation = $string_translation; $this->managers = array( 'fetcher' => $fetcher_manager, 'parser' => $parser_manager, @@ -95,7 +92,6 @@ public function __construct(ConfigFactory $config_factory, TranslationManager $s public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), - $container->get('string_translation'), $container->get('plugin.manager.aggregator.fetcher'), $container->get('plugin.manager.aggregator.parser'), $container->get('plugin.manager.aggregator.processor') @@ -118,11 +114,11 @@ public function buildForm(array $form, array &$form_state) { // Global aggregator settings. $form['aggregator_allowed_html_tags'] = array( '#type' => 'textfield', - '#title' => $this->translation->translate('Allowed HTML tags'), + '#title' => t('Allowed HTML tags'), '#size' => 80, '#maxlength' => 255, '#default_value' => $config->get('items.allowed_html'), - '#description' => $this->translation->translate('A space-separated list of HTML tags allowed in the content of feed items. Disallowed tags are stripped from the content.'), + '#description' => t('A space-separated list of HTML tags allowed in the content of feed items. Disallowed tags are stripped from the content.'), ); // Only show basic configuration if there are actually options. @@ -130,8 +126,8 @@ public function buildForm(array $form, array &$form_state) { if (count($this->definitions['fetcher']) > 1) { $basic_conf['aggregator_fetcher'] = array( '#type' => 'radios', - '#title' => $this->translation->translate('Fetcher'), - '#description' => $this->translation->translate('Fetchers download data from an external source. Choose a fetcher suitable for the external source you would like to download from.'), + '#title' => t('Fetcher'), + '#description' => t('Fetchers download data from an external source. Choose a fetcher suitable for the external source you would like to download from.'), '#options' => $this->definitions['fetcher'], '#default_value' => $config->get('fetcher'), ); @@ -139,8 +135,8 @@ public function buildForm(array $form, array &$form_state) { if (count($this->definitions['parser']) > 1) { $basic_conf['aggregator_parser'] = array( '#type' => 'radios', - '#title' => $this->translation->translate('Parser'), - '#description' => $this->translation->translate('Parsers transform downloaded data into standard structures. Choose a parser suitable for the type of feeds you would like to aggregate.'), + '#title' => t('Parser'), + '#description' => t('Parsers transform downloaded data into standard structures. Choose a parser suitable for the type of feeds you would like to aggregate.'), '#options' => $this->definitions['parser'], '#default_value' => $config->get('parser'), ); @@ -148,8 +144,8 @@ public function buildForm(array $form, array &$form_state) { if (count($this->definitions['processor']) > 1) { $basic_conf['aggregator_processors'] = array( '#type' => 'checkboxes', - '#title' => $this->translation->translate('Processors'), - '#description' => $this->translation->translate('Processors act on parsed feed data, for example they store feed items. Choose the processors suitable for your task.'), + '#title' => t('Processors'), + '#description' => t('Processors act on parsed feed data, for example they store feed items. Choose the processors suitable for your task.'), '#options' => $this->definitions['processor'], '#default_value' => $config->get('processors'), ); @@ -157,8 +153,8 @@ public function buildForm(array $form, array &$form_state) { if (count($basic_conf)) { $form['basic_conf'] = array( '#type' => 'details', - '#title' => $this->translation->translate('Basic configuration'), - '#description' => $this->translation->translate('For most aggregation tasks, the default settings are fine.'), + '#title' => t('Basic configuration'), + '#description' => t('For most aggregation tasks, the default settings are fine.'), '#collapsed' => FALSE, ); $form['basic_conf'] += $basic_conf; @@ -191,15 +187,7 @@ public function buildForm(array $form, array &$form_state) { } } - // @todo remove in https://drupal.org/node/2018411 or after its in. - $form['actions']['#type'] = 'actions'; - $form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => $this->translation->translate('Save configuration'), - '#button_type' => 'primary', - ); - $form['#theme'] = 'system_config_form'; - return $form; + return parent::buildForm($form, $form_state); } /** diff --git a/core/modules/aggregator/tests/Drupal/aggregator/Tests/Plugin/AggregatorPluginSettingsBaseTest.php b/core/modules/aggregator/tests/Drupal/aggregator/Tests/Plugin/AggregatorPluginSettingsBaseTest.php index 7523f9d..e5746ea 100644 --- a/core/modules/aggregator/tests/Drupal/aggregator/Tests/Plugin/AggregatorPluginSettingsBaseTest.php +++ b/core/modules/aggregator/tests/Drupal/aggregator/Tests/Plugin/AggregatorPluginSettingsBaseTest.php @@ -66,7 +66,6 @@ public function setUp() { $this->settingsForm = new SettingsForm( $this->configFactory, - $this->getStringTranslationStub(), $this->managers['fetcher'], $this->managers['parser'], $this->managers['processor'] @@ -111,9 +110,15 @@ public function testSettingsForm() { } -// @todo Remove after https://drupal.org/node/1830588 is in. namespace { + // @todo Remove after https://drupal.org/node/1858196 is in. if (!function_exists('drupal_set_message')) { function drupal_set_message() {} } + // @todo remove in https://drupal.org/node/2018411 or after its in. + if (!function_exists('t')) { + function t($string) { + return $string; + } + } } diff --git a/core/tests/Drupal/Tests/UnitTestCase.php b/core/tests/Drupal/Tests/UnitTestCase.php index b2e9d4a..1856011 100644 --- a/core/tests/Drupal/Tests/UnitTestCase.php +++ b/core/tests/Drupal/Tests/UnitTestCase.php @@ -134,20 +134,4 @@ public function getConfigStorageStub(array $configs) { return $config_storage; } - /** - * Returns a stub translation manager that just returns the passed string. - * - * @return \PHPUnit_Framework_MockObject_MockBuilder - * A MockBuilder object of \Drupal\Core\StringTranslation\TranslationManager - */ - public function getStringTranslationStub() { - $translation = $this->getMockBuilder('Drupal\Core\StringTranslation\TranslationManager') - ->disableOriginalConstructor() - ->getMock(); - $translation->expects($this->any()) - ->method('translate') - ->will($this->returnArgument(0)); - return $translation; - } - }