diff --git a/core/core.services.yml b/core/core.services.yml index 5997021..0b18c3b 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -736,6 +736,7 @@ services: arguments: ['%language.default_values%'] string_translator.custom_strings: class: Drupal\Core\StringTranslation\Translator\CustomStrings + arguments: ['@settings'] tags: - { name: string_translator, priority: 30 } string_translation: diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php b/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php index 0fbf9bf..8e733d5 100644 --- a/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php +++ b/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php @@ -3,6 +3,7 @@ namespace Drupal\Core\StringTranslation\Translator; use Drupal\Core\Site\Settings; +use Drupal\Core\DependencyInjection\DependencySerializationTrait; /** * String translator using overrides from variables. @@ -12,11 +13,31 @@ */ class CustomStrings extends StaticTranslation { + use DependencySerializationTrait; + + /** + * The settings read only object. + * + * @var \Drupal\Core\Site\Settings + */ + protected $settings; + + /** + * Constructs a CustomStrings object. + * + * @param \Drupal\Core\Site\Settings $settings + * The settings read only object. + */ + public function __construct(Settings $settings) { + parent::__construct(); + $this->settings = $settings; + } + /** * {@inheritdoc} */ protected function getLanguage($langcode) { - return Settings::get('locale_custom_strings_' . $langcode, array()); + return $this->settings->get('locale_custom_strings_' . $langcode, array()); } } diff --git a/core/modules/datetime/src/Tests/DateTimeFormInjectionTest.php b/core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php similarity index 84% rename from core/modules/datetime/src/Tests/DateTimeFormInjectionTest.php rename to core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php index 150c909..a65d439 100644 --- a/core/modules/datetime/src/Tests/DateTimeFormInjectionTest.php +++ b/core/modules/datetime/tests/src/Kernel/DateTimeFormInjectionTest.php @@ -1,19 +1,13 @@ installSchema('system', ['key_value_expire', 'sequences']); + } /** * {@inheritdoc} @@ -49,7 +51,7 @@ public function getFormId() { * Process callback. * * @param array $element - * Form element + * Form element. * * @return array * Processed element. @@ -62,21 +64,21 @@ public function process($element) { * {@inheritdoc} */ public function buildForm(array $form, FormStateInterface $form_state) { - $form['datelist_element'] = array( + $form['datelist_element'] = [ '#title' => 'datelist test', '#type' => 'datelist', '#default_value' => new DrupalDateTime('2000-01-01 00:00:00'), - '#date_part_order' => array( + '#date_part_order' => [ 'month', 'day', 'year', 'hour', 'minute', 'ampm', - ), - '#date_text_parts' => array('year'), + ], + '#date_text_parts' => ['year'], '#date_year_range' => '2010:2020', '#date_increment' => 15, - ); + ]; $form['#process'][] = [$this, 'process']; return $form; } @@ -95,15 +97,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { } /** - * {@inheritdoc} - */ - protected function setUp() { - parent::setUp(); - $this->installSchema('system', ['key_value_expire', 'sequences']); - } - - /** - * Tests db log injection serialization. + * Tests custom string injection serialization. */ public function testDatetimeSerialization() { $form_state = new FormState();