diff -u b/core/lib/Drupal/Core/Controller/ControllerBase.php b/core/lib/Drupal/Core/Controller/ControllerBase.php --- b/core/lib/Drupal/Core/Controller/ControllerBase.php +++ b/core/lib/Drupal/Core/Controller/ControllerBase.php @@ -33,2 +33,47 @@ /** + * @var \Drupal\Core\Entity\EntityManager + */ + protected $entityManager; + + /** + * @var \Drupal\Core\Language\LanguageManager + */ + protected $languageManager; + + /** + * @var \Drupal\Core\StringTranslation\TranslationInterface + */ + protected $translationManager; + + /** + * @var \Drupal\Core\Config\Config + */ + protected $configFactory; + + /** + * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + */ + protected $kv; + + /** + * @var \Drupal\Core\Routing\UrlGeneratorInterface + */ + protected $urlGenerator; + + /** + * @var \Drupal\Core\Session\AccountInterface + */ + protected $currentUser; + + /** + * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface + */ + protected $stateService; + + /** + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** * Retrieves the entity manager service. @@ -207,10 +252,7 @@ * The service container. */ protected function container() { - if (!$this->container) { - $this->container = \Drupal::getContainer(); - } - return $this->container; + return \Drupal::getContainer(); } /** only in patch2: unchanged: --- a/core/lib/Drupal/Core/Form/FormBase.php +++ b/core/lib/Drupal/Core/Form/FormBase.php @@ -75,7 +75,7 @@ protected function t($string, array $args = array(), array $options = array()) { */ protected function getTranslationManager() { if (!$this->translationManager) { - $this->translationManager = \Drupal::translation(); + $this->translationManager = $this->container()->get('string_translation'); } return $this->translationManager; } @@ -102,7 +102,7 @@ public function setTranslationManager(TranslationInterface $translation_manager) */ protected function getRequest() { if (!$this->request) { - $this->request = \Drupal::request(); + $this->request = $this->container()->get('request'); } return $this->request; } @@ -127,4 +127,14 @@ protected function getCurrentUser() { return $this->getRequest()->attributes->get('_account'); } + /** + * Returns the service container. + * + * @return \Symfony\Component\DependencyInjection\ContainerInterface $container + * The service container. + */ + protected function container() { + return \Drupal::getContainer(); + } + }