diff --git a/core/lib/Drupal/Core/Controller/ControllerBase.php b/core/lib/Drupal/Core/Controller/ControllerBase.php index 23a2cac..721f693 100644 --- a/core/lib/Drupal/Core/Controller/ControllerBase.php +++ b/core/lib/Drupal/Core/Controller/ControllerBase.php @@ -7,6 +7,8 @@ namespace Drupal\Core\Controller; +use Drupal\Core\DependencyInjection\ContainerInjectionInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\RedirectResponse; /** @@ -28,7 +30,7 @@ * * @see \Drupal\Core\DependencyInjection\ContainerInjectionInterface */ -abstract class ControllerBase { +abstract class ControllerBase implements ContainerInjectionInterface { /** * The entity manager. @@ -101,6 +103,13 @@ protected $formBuilder; /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static(); + } + + /** * Retrieves the entity manager service. * * @return \Drupal\Core\Entity\EntityManagerInterface diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php index f9b25b9..e327627 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\Xss; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\aggregator\FeedInterface; use Drupal\aggregator\ItemInterface; use Drupal\Core\Database\Connection; @@ -21,7 +20,7 @@ /** * Returns responses for aggregator module routes. */ -class AggregatorController extends ControllerBase implements ContainerInjectionInterface { +class AggregatorController extends ControllerBase { /** * The database connection. diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php index 6469baf..5f6c211 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php @@ -9,13 +9,12 @@ use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\custom_block\CustomBlockTypeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; -class CustomBlockController extends ControllerBase implements ContainerInjectionInterface { +class CustomBlockController extends ControllerBase { /** * The entity manager. diff --git a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php index 619ee96..fc04bd8 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php @@ -11,7 +11,6 @@ use Drupal\field\FieldInfo; use Drupal\Component\Utility\String; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Form\FormBuilderInterface; use Drupal\field_ui\FieldUI; use Symfony\Component\HttpFoundation\Request; @@ -20,7 +19,7 @@ /** * Returns responses for comment module administrative routes. */ -class AdminController extends ControllerBase implements ContainerInjectionInterface { +class AdminController extends ControllerBase { /** * The field info service. diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 73e8cfd..207be27 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -12,7 +12,6 @@ use Drupal\field\FieldInfo; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -26,7 +25,7 @@ * * @see \Drupal\comment\Entity\Comment. */ -class CommentController extends ControllerBase implements ContainerInjectionInterface { +class CommentController extends ControllerBase { /** * The HTTP kernel. diff --git a/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php b/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php index b791b30..0de4b8b 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php +++ b/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php @@ -10,14 +10,13 @@ use Drupal\comment\CommentStorageControllerInterface; use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Form\ConfirmFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides the comment multiple delete confirmation form. */ -class ConfirmDeleteMultiple extends ConfirmFormBase implements ContainerInjectionInterface { +class ConfirmDeleteMultiple extends ConfirmFormBase { /** * The comment storage. diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationController.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationController.php index 03c2a20..55e7318 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationController.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationController.php @@ -10,7 +10,6 @@ use Drupal\config_translation\ConfigMapperManagerInterface; use Drupal\Core\Access\AccessManager; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\PathProcessor\InboundPathProcessorInterface; @@ -25,7 +24,7 @@ /** * Provides page callbacks for the configuration translation interface. */ -class ConfigTranslationController extends ControllerBase implements ContainerInjectionInterface { +class ConfigTranslationController extends ControllerBase { /** * The configuration mapper manager. diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationListController.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationListController.php index e8bdad3..5d1430a 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationListController.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationListController.php @@ -9,14 +9,13 @@ use Drupal\config_translation\ConfigMapperManagerInterface; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Defines the configuration translation list controller. */ -class ConfigTranslationListController extends ControllerBase implements ContainerInjectionInterface { +class ConfigTranslationListController extends ControllerBase { /** * The definition of the config mapper. diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationMapperList.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationMapperList.php index b2242fd..8b7f63f 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationMapperList.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationMapperList.php @@ -10,7 +10,6 @@ use Drupal\Component\Utility\String; use Drupal\config_translation\ConfigMapperInterface; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -18,7 +17,7 @@ * * Groups all defined configuration mapper instances by weight. */ -class ConfigTranslationMapperList extends ControllerBase implements ContainerInjectionInterface { +class ConfigTranslationMapperList extends ControllerBase { /** * A array of configuration mapper instances. diff --git a/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php b/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php index ff5f71d..213cae4 100644 --- a/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php +++ b/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php @@ -8,7 +8,6 @@ namespace Drupal\contact\Controller; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Flood\FloodInterface; use Drupal\contact\CategoryInterface; use Drupal\user\UserInterface; @@ -20,7 +19,7 @@ /** * Controller routines for contact routes. */ -class ContactController extends ControllerBase implements ContainerInjectionInterface { +class ContactController extends ControllerBase { /** * The flood service. diff --git a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php index bc61820..9728f35 100644 --- a/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php +++ b/core/modules/dblog/lib/Drupal/dblog/Controller/DbLogController.php @@ -13,7 +13,6 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Database\Connection; use Drupal\Core\Datetime\Date; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBuilderInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -21,7 +20,7 @@ /** * Returns responses for dblog routes. */ -class DbLogController extends ControllerBase implements ContainerInjectionInterface { +class DbLogController extends ControllerBase { /** * The database service. diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php index d7c8386..2825383 100644 --- a/core/modules/edit/lib/Drupal/edit/EditController.php +++ b/core/modules/edit/lib/Drupal/edit/EditController.php @@ -7,29 +7,25 @@ namespace Drupal\edit; +use Drupal\Core\Controller\ControllerBase; 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; -use Drupal\Core\Form\FormBuilderInterface; use Drupal\field\FieldInfo; use Drupal\edit\Ajax\FieldFormCommand; use Drupal\edit\Ajax\FieldFormSavedCommand; use Drupal\edit\Ajax\FieldFormValidationErrorsCommand; use Drupal\edit\Ajax\EntitySavedCommand; -use Drupal\edit\Ajax\MetadataCommand; use Drupal\user\TempStoreFactory; /** * Returns responses for Edit module routes. */ -class EditController implements ContainerInjectionInterface { +class EditController extends ControllerBase { /** * The TempStore factory. @@ -53,13 +49,6 @@ class EditController implements ContainerInjectionInterface { protected $editorSelector; /** - * The entity manager. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - - /** * The field info service. * * @var \Drupal\field\FieldInfo @@ -67,20 +56,6 @@ class EditController implements ContainerInjectionInterface { protected $fieldInfo; /** - * The form builder. - * - * @var \Drupal\Core\Form\FormBuilderInterface - */ - protected $formBuilder; - - /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandlerInterface - */ - protected $moduleHandler; - - /** * Constructs a new EditController. * * @param \Drupal\user\TempStoreFactory $temp_store_factory @@ -89,23 +64,14 @@ class EditController implements ContainerInjectionInterface { * The in-place editing metadata generator. * @param \Drupal\edit\EditorSelectorInterface $editor_selector * The in-place editor selector. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. * @param \Drupal\field\FieldInfo $field_info * The field info service. - * @param \Drupal\Core\Form\FormBuilderInterface $form_builder - * The form builder. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. */ - public function __construct(TempStoreFactory $temp_store_factory, MetadataGeneratorInterface $metadata_generator, EditorSelectorInterface $editor_selector, EntityManagerInterface $entity_manager, FieldInfo $field_info, FormBuilderInterface $form_builder, ModuleHandlerInterface $module_handler) { + public function __construct(TempStoreFactory $temp_store_factory, MetadataGeneratorInterface $metadata_generator, EditorSelectorInterface $editor_selector, FieldInfo $field_info) { $this->tempStoreFactory = $temp_store_factory; $this->metadataGenerator = $metadata_generator; $this->editorSelector = $editor_selector; - $this->entityManager = $entity_manager; $this->fieldInfo = $field_info; - $this->formBuilder = $form_builder; - $this->moduleHandler = $module_handler; } /** @@ -116,10 +82,7 @@ public static function create(ContainerInterface $container) { $container->get('user.tempstore'), $container->get('edit.metadata.generator'), $container->get('edit.editor.selector'), - $container->get('entity.manager'), - $container->get('field.info'), - $container->get('form_builder'), - $container->get('module_handler') + $container->get('field.info') ); } @@ -145,10 +108,10 @@ public function metadata(Request $request) { list($entity_type, $entity_id, $field_name, $langcode, $view_mode) = explode('/', $field); // Load the entity. - if (!$entity_type || !$this->entityManager->getDefinition($entity_type)) { + if (!$entity_type || !$this->entityManager()->getDefinition($entity_type)) { throw new NotFoundHttpException(); } - $entity = $this->entityManager->getStorageController($entity_type)->load($entity_id); + $entity = $this->entityManager()->getStorageController($entity_type)->load($entity_id); if (!$entity) { throw new NotFoundHttpException(); } @@ -234,7 +197,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view 'args' => array($entity, $field_name), ), ); - $form = $this->formBuilder->buildForm('Drupal\edit\Form\EditFieldForm', $form_state); + $form = $this->formBuilder()->buildForm('Drupal\edit\Form\EditFieldForm', $form_state); if (!empty($form_state['executed'])) { // The form submission saved the entity in TempStore. Return the @@ -265,7 +228,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view else { $response->addCommand(new FieldFormCommand(drupal_render($form))); - $errors = $this->formBuilder->getErrors($form_state); + $errors = $this->formBuilder()->getErrors($form_state); if (count($errors)) { $status_messages = array( '#theme' => 'status_messages' @@ -324,7 +287,7 @@ public function renderField(EntityInterface $entity, $field_name, $langcode, $vi $mode_id_parts = explode('-', $view_mode_id, 2); $module = reset($mode_id_parts); $args = array($entity, $field_name, $view_mode_id, $langcode); - $output = $this->moduleHandler->invoke($module, 'edit_render_field', $args); + $output = $this->moduleHandler()->invoke($module, 'edit_render_field', $args); } return drupal_render($output); diff --git a/core/modules/entity/lib/Drupal/entity/Controller/EntityDisplayModeController.php b/core/modules/entity/lib/Drupal/entity/Controller/EntityDisplayModeController.php index 4d3ddc3..caa61ea 100644 --- a/core/modules/entity/lib/Drupal/entity/Controller/EntityDisplayModeController.php +++ b/core/modules/entity/lib/Drupal/entity/Controller/EntityDisplayModeController.php @@ -7,40 +7,12 @@ namespace Drupal\entity\Controller; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; -use Drupal\Core\Entity\EntityManagerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Controller\ControllerBase; /** * Provides methods for entity display mode routes. */ -class EntityDisplayModeController implements ContainerInjectionInterface { - - /** - * The entity manager. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - - /** - * Constructs a new EntityDisplayModeFormBase. - * - * @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') - ); - } +class EntityDisplayModeController extends ControllerBase { /** * Provides a list of eligible entity types for adding view modes. @@ -50,7 +22,7 @@ public static function create(ContainerInterface $container) { */ public function viewModeTypeSelection() { $entity_types = array(); - foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { + foreach ($this->entityManager()->getDefinitions() as $entity_type => $entity_info) { if ($entity_info->isFieldable() && $entity_info->hasViewBuilderClass()) { $entity_types[$entity_type] = array( 'title' => $entity_info->getLabel(), @@ -73,7 +45,7 @@ public function viewModeTypeSelection() { */ public function formModeTypeSelection() { $entity_types = array(); - foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { + foreach ($this->entityManager()->getDefinitions() as $entity_type => $entity_info) { if ($entity_info->isFieldable() && $entity_info->hasFormClasses()) { $entity_types[$entity_type] = array( 'title' => $entity_info->getLabel(), 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 6ee2db4..2dfda5d 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php @@ -7,18 +7,16 @@ namespace Drupal\entity_reference; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Controller\ControllerBase; 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 implements ContainerInjectionInterface { +class EntityReferenceController extends ControllerBase { /** * The autocomplete helper for entity references. @@ -28,23 +26,13 @@ class EntityReferenceController implements ContainerInjectionInterface { protected $entityReferenceAutocomplete; /** - * The entity manager. - * - * @var \Drupal\Core\Entity\EntityManagerInterface - */ - protected $entityManager; - - /** * Constructs a EntityReferenceController object. * - * @param \Drupal\entity_reference\EntityReferenceAutocomplete $entity_reference_autcompletion + * @param \Drupal\entity_reference\EntityReferenceAutocomplete $entity_reference_autocompletion * The autocompletion helper for entity references. - * @param \Drupal\Core\Entity\EntityManagerInterface ĂȘntity_manager - * The entity manager. */ - public function __construct(EntityReferenceAutocomplete $entity_reference_autcompletion, EntityManagerInterface $entity_manager) { - $this->entityReferenceAutocomplete = $entity_reference_autcompletion; - $this->entityManager = $entity_manager; + public function __construct(EntityReferenceAutocomplete $entity_reference_autocompletion) { + $this->entityReferenceAutocomplete = $entity_reference_autocompletion; } /** @@ -86,7 +74,7 @@ public function handleAutocomplete(Request $request, $type, $field_name, $entity throw new AccessDeniedHttpException(); } - $access_controller = $this->entityManager->getAccessController($entity_type); + $access_controller = $this->entityManager()->getAccessController($entity_type); if ($instance->getType() != 'entity_reference' || !$access_controller->fieldAccess('edit', $instance)) { throw new AccessDeniedHttpException(); } diff --git a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php index 2372e71..9222d1b 100644 --- a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php +++ b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php @@ -7,11 +7,7 @@ namespace Drupal\forum\Controller; -use Drupal\Core\Config\Config; -use Drupal\Core\Controller\ControllerInterface; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; -use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\StringTranslation\TranslationInterface; +use Drupal\Core\Controller\ControllerBase; use Drupal\forum\ForumManagerInterface; use Drupal\taxonomy\TermInterface; use Drupal\taxonomy\TermStorageControllerInterface; @@ -21,7 +17,7 @@ /** * Controller routines for forum routes. */ -class ForumController implements ContainerInjectionInterface { +class ForumController extends ControllerBase { /** * Forum manager service. @@ -31,20 +27,6 @@ class ForumController implements ContainerInjectionInterface { 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 @@ -59,35 +41,19 @@ class ForumController implements ContainerInjectionInterface { 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; } /** @@ -95,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') ); } @@ -115,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)) { @@ -134,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)) { @@ -164,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)) { @@ -188,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'); } /** @@ -203,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 7aac826..59cf945 100644 --- a/core/modules/help/lib/Drupal/help/Controller/HelpController.php +++ b/core/modules/help/lib/Drupal/help/Controller/HelpController.php @@ -1,4 +1,5 @@ moduleHandler = $module_handler; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static($container->get('module_handler')); - } +class HelpController extends ControllerBase { /** * Prints a page listing a glossary of Drupal terminology. @@ -52,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; } @@ -68,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']; } } @@ -81,7 +56,7 @@ protected function helpLinksAsList() { $output = '