diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php index 2be0b5e..38e5424 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php @@ -18,32 +18,6 @@ class EntityViewController extends ControllerBase { /** - * The entity manager - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - - /** - * Creates an EntityListController object. - * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. - */ - public function __construct(EntityManagerInterface $entity_manager) { - $this->entityManager = $entity_manager; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.manager') - ); - } - - /** * Provides a page to render a single entity. * * @param \Drupal\Core\Entity\EntityInterface $_entity @@ -61,7 +35,7 @@ public static function create(ContainerInterface $container) { * A render array as expected by drupal_render(). */ public function view(EntityInterface $_entity, $view_mode = 'full', $langcode = NULL) { - return $this->entityManager + return $this->entityManager() ->getViewBuilder($_entity->entityType()) ->view($_entity, $view_mode, $langcode); } diff --git a/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php b/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php index 2556211..02e9a4f 100644 --- a/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php +++ b/core/modules/block/lib/Drupal/block/Controller/CategoryAutocompleteController.php @@ -9,7 +9,7 @@ use Drupal\block\Plugin\Type\BlockManager; use Drupal\Component\Utility\String; -use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; @@ -17,7 +17,7 @@ /** * Returns autocomplete responses for block categories. */ -class CategoryAutocompleteController extends ControllerBase { +class CategoryAutocompleteController implements ContainerInjectionInterface { /** * The block manager. diff --git a/core/modules/book/lib/Drupal/book/Controller/BookController.php b/core/modules/book/lib/Drupal/book/Controller/BookController.php index 2bf2a9b..b9920d2 100644 --- a/core/modules/book/lib/Drupal/book/Controller/BookController.php +++ b/core/modules/book/lib/Drupal/book/Controller/BookController.php @@ -9,7 +9,7 @@ use Drupal\book\BookManager; use Drupal\book\BookExport; -use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\node\NodeInterface; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -19,7 +19,7 @@ /** * Controller routines for book routes. */ -class BookController extends ControllerBase { +class BookController implements ContainerInjectionInterface { /** * The book manager. diff --git a/core/modules/config/lib/Drupal/config/Controller/ConfigController.php b/core/modules/config/lib/Drupal/config/Controller/ConfigController.php index 005ba54..a1e8510 100644 --- a/core/modules/config/lib/Drupal/config/Controller/ConfigController.php +++ b/core/modules/config/lib/Drupal/config/Controller/ConfigController.php @@ -9,7 +9,7 @@ use Drupal\Component\Archiver\ArchiveTar; use Drupal\Core\Config\StorageInterface; -use Drupal\Core\Controller\ControllerBase; +use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\system\FileDownloadController; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -17,7 +17,7 @@ /** * Returns responses for config module routes. */ -class ConfigController extends ControllerBase { +class ConfigController implements ContainerInjectionInterface { /** * The target storage. diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php index 6be8d91..2c14041 100644 --- a/core/modules/edit/lib/Drupal/edit/EditController.php +++ b/core/modules/edit/lib/Drupal/edit/EditController.php @@ -7,13 +7,14 @@ namespace Drupal\edit; -use Drupal\Core\Controller\ControllerBase; +use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Drupal\Component\Utility\MapArray; use Drupal\Core\Ajax\AjaxResponse; +use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; @@ -25,12 +26,13 @@ use Drupal\edit\Ajax\FieldFormValidationErrorsCommand; use Drupal\edit\Ajax\EntitySavedCommand; use Drupal\edit\Ajax\MetadataCommand; +use Drupal\edit\Form\EditFieldForm; use Drupal\user\TempStoreFactory; /** * Returns responses for Edit module routes. */ -class EditController extends ControllerBase { +class EditController extends ContainerAware implements ContainerInjectionInterface { /** * The TempStore factory. @@ -216,14 +218,16 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view $this->tempStoreFactory->get('edit')->set($entity->uuid(), $entity); } + $form_object = EditFieldForm::create($this->container); $form_state = array( 'langcode' => $langcode, 'no_redirect' => TRUE, 'build_info' => array( 'args' => array($entity, $field_name), + 'callback_object' => $form_object, ), ); - $form = drupal_build_form('Drupal\edit\Form\EditFieldForm', $form_state); + $form = drupal_build_form($form_object->getFormId(), $form_state); if (!empty($form_state['executed'])) { // The form submission saved the entity in TempStore. Return the diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php index 4d786f7..6ee2db4 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php @@ -7,17 +7,18 @@ namespace Drupal\entity_reference; -use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Drupal\Core\Controller\ControllerInterface; /** * Defines route controller for entity reference. */ -class EntityReferenceController extends ControllerBase { +class EntityReferenceController implements ContainerInjectionInterface { /** * The autocomplete helper for entity references. diff --git a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php index e2880f3..9222d1b 100644 --- a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php +++ b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php @@ -7,10 +7,7 @@ namespace Drupal\forum\Controller; -use Drupal\Core\Config\Config; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\StringTranslation\TranslationInterface; use Drupal\forum\ForumManagerInterface; use Drupal\taxonomy\TermInterface; use Drupal\taxonomy\TermStorageControllerInterface; @@ -30,20 +27,6 @@ class ForumController extends ControllerBase { protected $forumManager; /** - * Entity Manager Service. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - - /** - * Config object for forum.settings. - * - * @var \Drupal\Core\Config\Config - */ - protected $config; - - /** * Vocabulary storage controller. * * @var \Drupal\taxonomy\VocabularyStorageControllerInterface @@ -58,35 +41,19 @@ class ForumController extends ControllerBase { protected $termStorageController; /** - * Translation manager service. - * - * @var \Drupal\Core\StringTranslation\TranslationInterface - */ - protected $translationManager; - - /** * Constructs a ForumController object. * - * @param \Drupal\Core\Config\Config $config - * Config object for forum.settings. * @param \Drupal\forum\ForumManagerInterface $forum_manager * The forum manager service. * @param \Drupal\taxonomy\VocabularyStorageControllerInterface $vocabulary_storage_controller * Vocabulary storage controller. * @param \Drupal\taxonomy\TermStorageControllerInterface $term_storage_controller * Term storage controller. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager service. - * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager - * The translation manager service. */ - public function __construct(Config $config, ForumManagerInterface $forum_manager, VocabularyStorageControllerInterface $vocabulary_storage_controller, TermStorageControllerInterface $term_storage_controller, EntityManagerInterface $entity_manager, TranslationInterface $translation_manager) { - $this->config = $config; + public function __construct(ForumManagerInterface $forum_manager, VocabularyStorageControllerInterface $vocabulary_storage_controller, TermStorageControllerInterface $term_storage_controller) { $this->forumManager = $forum_manager; $this->vocabularyStorageController = $vocabulary_storage_controller; $this->termStorageController = $term_storage_controller; - $this->entityManager = $entity_manager; - $this->translationManager = $translation_manager; } /** @@ -94,12 +61,9 @@ public function __construct(Config $config, ForumManagerInterface $forum_manager */ public static function create(ContainerInterface $container) { return new static( - $container->get('config.factory')->get('forum.settings'), $container->get('forum_manager'), $container->get('entity.manager')->getStorageController('taxonomy_vocabulary'), - $container->get('entity.manager')->getStorageController('taxonomy_term'), - $container->get('entity.manager'), - $container->get('string_translation') + $container->get('entity.manager')->getStorageController('taxonomy_term') ); } @@ -114,7 +78,7 @@ public static function create(ContainerInterface $container) { */ public function forumPage(TermInterface $taxonomy_term) { // Get forum details. - $taxonomy_term->forums = $this->forumManager->getChildren($this->config->get('vocabulary'), $taxonomy_term->id()); + $taxonomy_term->forums = $this->forumManager->getChildren($this->config('forum.settings')->get('vocabulary'), $taxonomy_term->id()); $taxonomy_term->parents = $this->forumManager->getParents($taxonomy_term->id()); if (empty($taxonomy_term->forum_container->value)) { @@ -133,7 +97,7 @@ public function forumPage(TermInterface $taxonomy_term) { * A render array. */ public function forumIndex() { - $vocabulary = $this->vocabularyStorageController->load($this->config->get('vocabulary')); + $vocabulary = $this->vocabularyStorageController->load($this->config('forum.settings')->get('vocabulary')); $index = $this->forumManager->getIndex(); $build = $this->build($index->forums, $index); if (empty($index->forums)) { @@ -163,14 +127,15 @@ public function forumIndex() { * A render array. */ protected function build($forums, TermInterface $term, $topics = array(), $parents = array()) { + $config = $this->config('forum.settings'); $build = array( '#theme' => 'forums', '#forums' => $forums, '#topics' => $topics, '#parents' => $parents, '#term' => $term, - '#sortby' => $this->config->get('topics.order'), - '#forums_per_page' => $this->config->get('topics.page_limit'), + '#sortby' => $config->get('topics.order'), + '#forums_per_page' => $config->get('topics.page_limit'), ); $build['#attached']['library'][] = array('forum', 'forum.index'); if (empty($term->forum_container->value)) { @@ -187,12 +152,12 @@ protected function build($forums, TermInterface $term, $topics = array(), $paren * Render array for the add form. */ public function addForum() { - $vid = $this->config->get('vocabulary'); + $vid = $this->config('forum.settings')->get('vocabulary'); $taxonomy_term = $this->termStorageController->create(array( 'vid' => $vid, 'forum_controller' => 0, )); - return $this->entityManager->getForm($taxonomy_term, 'forum'); + return $this->entityManager()->getForm($taxonomy_term, 'forum'); } /** @@ -202,21 +167,12 @@ public function addForum() { * Render array for the add form. */ public function addContainer() { - $vid = $this->config->get('vocabulary'); + $vid = $this->config('forum.settings')->get('vocabulary'); $taxonomy_term = $this->termStorageController->create(array( 'vid' => $vid, 'forum_container' => 1, )); - return $this->entityManager->getForm($taxonomy_term, 'container'); - } - - /** - * Translates a string to the current language or to a given language. - * - * See the t() documentation for details. - */ - protected function t($string, array $args = array(), array $options = array()) { - return $this->translationManager->translate($string, $args, $options); + return $this->entityManager()->getForm($taxonomy_term, 'container'); } } diff --git a/core/modules/help/lib/Drupal/help/Controller/HelpController.php b/core/modules/help/lib/Drupal/help/Controller/HelpController.php index 00652bb..59cf945 100644 --- a/core/modules/help/lib/Drupal/help/Controller/HelpController.php +++ b/core/modules/help/lib/Drupal/help/Controller/HelpController.php @@ -8,8 +8,6 @@ namespace Drupal\help\Controller; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\Extension\ModuleHandlerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Drupal\Component\Utility\String; @@ -19,30 +17,6 @@ class HelpController extends ControllerBase { /** - * Stores the module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** - * Constructs a \Drupal\help\Controller\HelpController object. - * - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. - */ - public function __construct(ModuleHandlerInterface $module_handler) { - $this->moduleHandler = $module_handler; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static($container->get('module_handler')); - } - - /** * Prints a page listing a glossary of Drupal terminology. * * @return string @@ -53,7 +27,7 @@ public function helpMain() { '#attached' => array( 'css' => array(drupal_get_path('module', 'help') . '/css/help.module.css'), ), - '#markup' => '

' . t('Help topics') . '

' . t('Help is available on the following items:') . '

' . $this->helpLinksAsList(), + '#markup' => '

' . $this->t('Help topics') . '

' . $this->t('Help is available on the following items:') . '

' . $this->helpLinksAsList(), ); return $output; } @@ -69,8 +43,8 @@ protected function helpLinksAsList() { $module_info = system_rebuild_module_data(); $modules = array(); - foreach ($this->moduleHandler->getImplementations('help') as $module) { - if ($this->moduleHandler->invoke($module, 'help', array("admin/help#$module", $empty_arg))) { + foreach ($this->moduleHandler()->getImplementations('help') as $module) { + if ($this->moduleHandler()->invoke($module, 'help', array("admin/help#$module", $empty_arg))) { $modules[$module] = $module_info[$module]->info['name']; } } @@ -82,7 +56,7 @@ protected function helpLinksAsList() { $output = '