diff --git a/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php b/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php
index 72b9ba6..5d813f2 100644
--- a/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php
+++ b/core/modules/locale/lib/Drupal/locale/Controller/LocaleController.php
@@ -6,7 +6,7 @@
namespace Drupal\locale\Controller;
-use Drupal\Core\Controller\ControllerInterface;
+use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\locale\Form\TranslateEditForm;
@@ -17,7 +17,7 @@
/**
* Return response for manual check translations.
*/
-class LocaleController implements ControllerInterface {
+class LocaleController extends ControllerBase {
/**
* The module handler.
@@ -27,37 +27,11 @@ class LocaleController implements ControllerInterface {
protected $moduleHandler;
/**
- * The container.
- *
- * @var \Symfony\Component\DependencyInjection\ContainerInterface
- */
- protected $container;
-
- /**
* Constructs a \Drupal\locale\Controller\LocaleController object.
- *
- * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
- * The module handler.
- * @param \Drupal\Core\Routing\PathBasedGeneratorInterface $url_generator
- * The URL generator service.
- * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
- * The service container this object should use.
*/
- public function __construct(ModuleHandlerInterface $module_handler, UrlGeneratorInterface $url_generator) {
- $this->moduleHandler = $module_handler;
- $this->urlGenerator = $url_generator;
- $this->container = $container;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('module_handler'),
- $container->get('url_generator'),
- $container
- );
+ public function __construct() {
+ $this->moduleHandler = $this->container->get('module_handler');
+ $this->urlGenerator = $this->container->get('url_generator');
}
/**
@@ -88,8 +62,6 @@ public function checkTranslation() {
/**
* Shows the string search screen.
- *
- * @see locale_menu()
*/
public function translatePage() {
return array(
diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php
index 15541fe..7fabd5d 100644
--- a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php
+++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php
@@ -9,11 +9,7 @@
use Drupal\Component\Utility\String;
use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
-use Drupal\Core\StringTranslation\Translator\TranslatorInterface;
use Drupal\locale\SourceString;
-use Drupal\locale\StringStorageInterface;
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\Request;
/**
* Defines a translation edit form.
@@ -28,55 +24,11 @@ class TranslateEditForm extends TranslateFormBase {
protected $state;
/**
- * The translationManager service.
- *
- * @var \Drupal\Core\StringTranslation\Translator\TranslatorInterface
- */
- protected $translationManager;
-
- /**
- *
- * Constructs a new TranslateEditForm object.
- *
- * @param \Drupal\locale\StringStorageInterface $locale_storage
- * The locale storage.
- */
-
- /**
* Constructs a new TranslateEditForm object.
- *
- * @param \Drupal\locale\StringStorageInterface $locale_storage
- * The locale storage.
- * @param \Symfony\Component\HttpFoundation\Request $request
- * The request for this page.
- * @param \Drupal\Core\StringTranslation\Translator\TranslatorInterface $translationManager
- * The translation interface to be appended to the translation chain.
- * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state
- * The state key/value store.
*/
- public function __construct(StringStorageInterface $locale_storage, Request $request, TranslatorInterface $translationManager, KeyValueStoreInterface $state) {
- parent::__construct($locale_storage, $request, $translationManager);
- $this->state = $state;
- }
-
- /**
- * Instantiates a new instance of this form.
- *
- * This is a factory method that returns a new instance of this object. The
- * factory should pass any needed dependencies into the constructor of this
- * object, but not the container itself. Every call to this method must return
- * a new instance of this object; that is, it may not implement a singleton.
- *
- * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
- * The service container this object should use.
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('locale.storage'),
- $container->get('request'),
- $container->get('string_translation'),
- $container->get('keyvalue')->get('state')
- );
+ public function __construct() {
+ parent::__construct();
+ $this->state = $this->container->get('keyvalue')->get('state');
}
/**
@@ -135,7 +87,7 @@ public function buildForm(array $form, array &$form_state) {
);
$form['strings'][$string->lid]['original'] = array(
'#type' => 'item',
- '#title' => $this->translationManager->translate('Source string (@language)', array('@language' => $this->translationManager->translate('Built-in English'))),
+ '#title' => $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))),
'#title_display' => 'invisible',
'#markup' => '' . String::checkPlain($source_array[0]) . '',
);
@@ -148,13 +100,13 @@ public function buildForm(array $form, array &$form_state) {
);
$form['strings'][$string->lid]['original_singular'] = array(
'#type' => 'item',
- '#title' => $this->translationManager->translate('Singular form'),
+ '#title' => $this->t('Singular form'),
'#markup' => '' . String::checkPlain($source_array[0]) . '',
- '#prefix' => '' . $this->translationManager->translate('Source string (@language)', array('@language' => $this->translationManager->translate('Built-in English'))) . ''
+ '#prefix' => '' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . ''
);
$form['strings'][$string->lid]['original_plural'] = array(
'#type' => 'item',
- '#title' => $this->translationManager->translate('Plural form'),
+ '#title' => $this->t('Plural form'),
'#markup' => '' . String::checkPlain($source_array[1]) . '',
);
}
@@ -169,7 +121,7 @@ public function buildForm(array $form, array &$form_state) {
if (empty($form['strings'][$string->lid]['plural']['#value'])) {
$form['strings'][$string->lid]['translations'][0] = array(
'#type' => 'textarea',
- '#title' => $this->translationManager->translate('Translated string (@language)', array('@language' => $langname)),
+ '#title' => $this->t('Translated string (@language)', array('@language' => $langname)),
'#title_display' => 'invisible',
'#rows' => $rows,
'#default_value' => $translation_array[0],
@@ -183,11 +135,11 @@ public function buildForm(array $form, array &$form_state) {
for ($i = 0; $i < $plural_formulas[$langcode]['plurals']; $i++) {
$form['strings'][$string->lid]['translations'][$i] = array(
'#type' => 'textarea',
- '#title' => ($i == 0 ? $this->translationManager->translate('Singular form') : format_plural($i, 'First plural form', '@count. plural form')),
+ '#title' => ($i == 0 ? $this->t('Singular form') : format_plural($i, 'First plural form', '@count. plural form')),
'#rows' => $rows,
'#default_value' => isset($translation_array[$i]) ? $translation_array[$i] : '',
'#attributes' => array('lang' => $langcode),
- '#prefix' => $i == 0 ? ('' . $this->translationManager->translate('Translated string (@language)', array('@language' => $langname)) . '') : '',
+ '#prefix' => $i == 0 ? ('' . $this->t('Translated string (@language)', array('@language' => $langname)) . '') : '',
);
}
}
@@ -195,15 +147,15 @@ public function buildForm(array $form, array &$form_state) {
// Fallback for unknown number of plurals.
$form['strings'][$string->lid]['translations'][0] = array(
'#type' => 'textarea',
- '#title' => $this->translationManager->translate('Singular form'),
+ '#title' => $this->t('Singular form'),
'#rows' => $rows,
'#default_value' => $translation_array[0],
'#attributes' => array('lang' => $langcode),
- '#prefix' => '' . $this->translationManager->translate('Translated string (@language)', array('@language' => $langname)) . '',
+ '#prefix' => '' . $this->t('Translated string (@language)', array('@language' => $langname)) . '',
);
$form['strings'][$string->lid]['translations'][1] = array(
'#type' => 'textarea',
- '#title' => $this->translationManager->translate('Plural form'),
+ '#title' => $this->t('Plural form'),
'#rows' => $rows,
'#default_value' => isset($translation_array[1]) ? $translation_array[1] : '',
'#attributes' => array('lang' => $langcode),
@@ -215,7 +167,7 @@ public function buildForm(array $form, array &$form_state) {
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
- '#value' => $this->translationManager->translate('Save translations'),
+ '#value' => $this->t('Save translations'),
);
}
}
@@ -230,8 +182,8 @@ public function validateForm(array &$form, array &$form_state) {
foreach ($form_state['values']['strings'] as $lid => $translations) {
foreach ($translations['translations'] as $key => $value) {
if (!locale_string_is_safe($value)) {
- form_set_error("strings][$lid][translations][$key", $this->translationManager->translate('The submitted string contains disallowed HTML: %string', array('%string' => $value)));
- form_set_error("translations][$langcode][$key", $this->translationManager->translate('The submitted string contains disallowed HTML: %string', array('%string' => $value)));
+ form_set_error("strings][$lid][translations][$key", $this->t('The submitted string contains disallowed HTML: %string', array('%string' => $value)));
+ form_set_error("translations][$langcode][$key", $this->t('The submitted string contains disallowed HTML: %string', array('%string' => $value)));
watchdog('locale', 'Attempted submission of a translation string with disallowed HTML: %string', array('%string' => $value), WATCHDOG_WARNING);
}
}
@@ -241,7 +193,7 @@ public function validateForm(array &$form, array &$form_state) {
/**
* {@inheritdoc}
*/
- public function submitForm(array &$form, array &$form_state, Request $request = NULL) {
+ public function submitForm(array &$form, array &$form_state) {
$langcode = $form_state['values']['langcode'];
$updated = array();
@@ -290,7 +242,7 @@ public function submitForm(array &$form, array &$form_state, Request $request =
}
}
- drupal_set_message($this->translationManager->translate('The strings have been saved.'));
+ drupal_set_message($this->t('The strings have been saved.'));
// Keep the user on the current pager page.
$page = $this->request->query->get('page');
diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php
index 07ed4d7..8ad8dcf 100644
--- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php
+++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php
@@ -32,7 +32,7 @@ public function buildForm(array $form, array &$form_state) {
$form['filters'] = array(
'#type' => 'details',
- '#title' => t('Filter translatable strings'),
+ '#title' => $this->t('Filter translatable strings'),
'#collapsed' => FALSE,
);
foreach ($filters as $key => $filter) {
@@ -68,12 +68,12 @@ public function buildForm(array $form, array &$form_state) {
);
$form['filters']['actions']['submit'] = array(
'#type' => 'submit',
- '#value' => t('Filter'),
+ '#value' => $this->t('Filter'),
);
if (!empty($_SESSION['locale_translate_filter'])) {
$form['filters']['actions']['reset'] = array(
'#type' => 'submit',
- '#value' => t('Reset'),
+ '#value' => $this->t('Reset'),
);
}
@@ -93,7 +93,7 @@ public function submitForm(array &$form, array &$form_state) {
$op = $form_state['values']['op'];
$filters = $this->translateFilters();
switch ($op) {
- case $this->translationManager->translate('Filter'):
+ case $this->t('Filter'):
foreach ($filters as $name => $filter) {
if (isset($form_state['values'][$name])) {
$_SESSION['locale_translate_filter'][$name] = $form_state['values'][$name];
@@ -101,7 +101,7 @@ public function submitForm(array &$form, array &$form_state) {
}
break;
- case $this->translationManager->translate('Reset'):
+ case $this->t('Reset'):
$_SESSION['locale_translate_filter'] = array();
break;
}
diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php
index dabac99..317b989 100644
--- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php
+++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php
@@ -7,20 +7,15 @@
namespace Drupal\locale\Form;
-use Drupal\Core\Controller\ControllerInterface;
-use Drupal\Core\Form\FormInterface;
-use Drupal\Core\StringTranslation\TranslationManager;
-use Drupal\Core\Language\Language;
+use Drupal\Core\Form\FormBase;
use Drupal\locale\StringStorageInterface;
-use Symfony\Component\DependencyInjection\ContainerInterface;
-use Symfony\Component\HttpFoundation\Request;
/**
* Defines the locale user interface translation form base.
*
* Provides methods for searching and filtering strings.
*/
-abstract class TranslateFormBase implements ControllerInterface, FormInterface {
+abstract class TranslateFormBase extends FormBase {
/**
* The locale storage.
@@ -29,73 +24,31 @@
*/
protected $localeStorage;
- /**
- * The current request.
- *
- * @var \Symfony\Component\HttpFoundation\Request
- */
- protected $request;
-
- /**
- * The translation manager service.
- *
- * @var \Drupal\Core\StringTranslation\TranslationManager
- */
- protected $translationManager;
-
- /**
+ /*
* Filter values. Shared between objects that inherite this class.
*
* @var array | null
*/
public static $filter_values = NULL;
-
+
/**
* Constructs a new TranslationFormBase object.
*
- * @param \Drupal\locale\StringStorageInterface $locale_storage
- * The locale storage.
- * @param \Symfony\Component\HttpFoundation\Request $request
- * The request for this page.
- * @param \Drupal\Core\StringTranslation\TranslationManager $translation_manager
* The translation manager service.
*/
- public function __construct(StringStorageInterface $locale_storage, Request $request, TranslationManager $translation_manager) {
- $this->localeStorage = $locale_storage;
- $this->request = $request;
- $this->translationManager = $translation_manager;
+ public function __construct() {
+ $this->localeStorage = $this->container->get('locale.storage');
}
- /**
- * Instantiates a new instance of this form.
- *
- * This is a factory method that returns a new instance of this object. The
- * factory should pass any needed dependencies into the constructor of this
- * object, but not the container itself. Every call to this method must return
- * a new instance of this object; that is, it may not implement a singleton.
- *
- * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
- * The service container this object should use.
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('locale.storage'),
- $container->get('request'),
- $container->get('string_translation')
- );
- }
/**
* Builds a string search query and returns an array of string objects.
*
- * @param \Symfony\Component\HttpFoundation\Request $request
- * The current request object.
- *
* @return array
* Array of \Drupal\locale\TranslationString objects.
*/
- protected function translateFilterLoadStrings(Request $request) {
- $filter_values = $this->translateFilterValues($request);
+ protected function translateFilterLoadStrings() {
+ $filter_values = $this->translateFilterValues($this->request);
// Language is sanitized to be one of the possible options in
// translateFilterValues().
@@ -130,13 +83,10 @@ protected function translateFilterLoadStrings(Request $request) {
/**
* Builds an array out of search criteria specified in request variables.
*
- * @param \Symfony\Component\HttpFoundation\Request $request
- * The current request object.
- *
* @return array $filter_values
* The filter values.
*/
- protected function translateFilterValues(Request $request, $reset=FALSE) {
+ protected function translateFilterValues($reset=FALSE) {
if (!$reset && static::$filter_values) {
return static::$filter_values;
}
@@ -146,10 +96,10 @@ protected function translateFilterValues(Request $request, $reset=FALSE) {
foreach ($filters as $key => $filter) {
$filter_values[$key] = $filter['default'];
// Let the filter defaults be overwritten by parameters in the URL.
- if ($request->query->has($key)) {
+ if ($this->request->query->has($key)) {
// Only allow this value if it was among the options, or
// if there were no fixed options to filter for.
- $value = $request->query->get($key);
+ $value = $this->request->query->get($key);
if (!isset($filter['options']) || isset($filter['options'][$value])) {
$filter_values[$key] = $value;
}
@@ -162,7 +112,7 @@ protected function translateFilterValues(Request $request, $reset=FALSE) {
}
}
}
-
+
return static::$filter_values = $filter_values;
}
@@ -190,33 +140,33 @@ protected function translateFilters() {
}
$filters['string'] = array(
- 'title' => $this->translationManager->translate('String contains'),
- 'description' => $this->translationManager->translate('Leave blank to show all strings. The search is case sensitive.'),
+ 'title' => $this->t('String contains'),
+ 'description' => $this->t('Leave blank to show all strings. The search is case sensitive.'),
'default' => '',
);
$filters['langcode'] = array(
- 'title' => $this->translationManager->translate('Translation language'),
+ 'title' => $this->t('Translation language'),
'options' => $language_options,
'default' => $default_langcode,
);
$filters['translation'] = array(
- 'title' => $this->translationManager->translate('Search in'),
+ 'title' => $this->t('Search in'),
'options' => array(
- 'all' => $this->translationManager->translate('Both translated and untranslated strings'),
- 'translated' => $this->translationManager->translate('Only translated strings'),
- 'untranslated' => $this->translationManager->translate('Only untranslated strings'),
+ 'all' => $this->t('Both translated and untranslated strings'),
+ 'translated' => $this->t('Only translated strings'),
+ 'untranslated' => $this->t('Only untranslated strings'),
),
'default' => 'all',
);
$filters['customized'] = array(
- 'title' => $this->translationManager->translate('Translation type'),
+ 'title' => $this->t('Translation type'),
'options' => array(
- 'all' => $this->translationManager->translate('All'),
- LOCALE_NOT_CUSTOMIZED => $this->translationManager->translate('Non-customized translation'),
- LOCALE_CUSTOMIZED => $this->translationManager->translate('Customized translation'),
+ 'all' => $this->t('All'),
+ LOCALE_NOT_CUSTOMIZED => $this->t('Non-customized translation'),
+ LOCALE_CUSTOMIZED => $this->t('Customized translation'),
),
'states' => array(
'visible' => array(