diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php index 7fabd5d..686e60e 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php @@ -7,8 +7,8 @@ namespace Drupal\locale\Form; -use Drupal\Component\Utility\String; use Drupal\Core\KeyValueStore\KeyValueStoreInterface; +use Drupal\Component\Utility\String; use Drupal\locale\SourceString; /** @@ -42,7 +42,7 @@ public function getFormID() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $filter_values = $this->translateFilterValues($this->request); + $filter_values = $this->translateFilterValues(); $langcode = $filter_values['langcode']; drupal_static_reset('language_list'); @@ -69,7 +69,7 @@ public function buildForm(array $form, array &$form_state) { ); if (isset($langcode)) { - $strings = $this->translateFilterLoadStrings($this->request); + $strings = $this->translateFilterLoadStrings(); $plural_formulas = $this->state->get('locale.translation.plurals') ?: array(); @@ -245,7 +245,7 @@ public function submitForm(array &$form, array &$form_state) { drupal_set_message($this->t('The strings have been saved.')); // Keep the user on the current pager page. - $page = $this->request->query->get('page'); + $page = $this->getRequest()->query->get('page'); if (isset($page)) { $form_state['redirect'] = array('admin/config/regional/translate', array('query' => array('page' => $page))); } diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php index 8ad8dcf..caaba77 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php @@ -24,7 +24,7 @@ public function getFormID() { */ public function buildForm(array $form, array &$form_state) { $filters = $this->translateFilters(); - $filter_values = $this->translateFilterValues($this->request); + $filter_values = $this->translateFilterValues(); $form['#attached']['css'] = array( drupal_get_path('module', 'locale') . '/css/locale.admin.css', diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php index 317b989..03b25b2 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php @@ -9,6 +9,7 @@ use Drupal\Core\Form\FormBase; use Drupal\locale\StringStorageInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines the locale user interface translation form base. @@ -24,6 +25,13 @@ */ protected $localeStorage; + /** + * The service container. + * + * @var \Symfony\Component\DependencyInjection\ContainerInterface + */ + protected $container; + /* * Filter values. Shared between objects that inherite this class. * @@ -36,10 +44,27 @@ * * The translation manager service. */ - public function __construct() { + public function __construct(ContainerInterface $container) { + $this->container = $container; $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 retur + * a new instance of this object; that is, it may not implement a singleton. + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $containe + * The service container this object should use. + */ + public static function create(ContainerInterface $container) { + return new static( + $container + ); + } /** * Builds a string search query and returns an array of string objects. @@ -48,7 +73,7 @@ public function __construct() { * Array of \Drupal\locale\TranslationString objects. */ protected function translateFilterLoadStrings() { - $filter_values = $this->translateFilterValues($this->request); + $filter_values = $this->translateFilterValues(); // Language is sanitized to be one of the possible options in // translateFilterValues(). @@ -86,7 +111,7 @@ protected function translateFilterLoadStrings() { * @return array $filter_values * The filter values. */ - protected function translateFilterValues($reset=FALSE) { + protected function translateFilterValues($reset = FALSE) { if (!$reset && static::$filter_values) { return static::$filter_values; } @@ -96,10 +121,10 @@ protected function translateFilterValues($reset=FALSE) { foreach ($filters as $key => $filter) { $filter_values[$key] = $filter['default']; // Let the filter defaults be overwritten by parameters in the URL. - if ($this->request->query->has($key)) { + if ($this->getRequest()->query->has($key)) { // Only allow this value if it was among the options, or // if there were no fixed options to filter for. - $value = $this->request->query->get($key); + $value = $this->getRequest()->query->get($key); if (!isset($filter['options']) || isset($filter['options'][$value])) { $filter_values[$key] = $value; }