diff --git a/core/lib/Drupal/Core/Config/Entity/DraggableListController.php b/core/lib/Drupal/Core/Config/Entity/DraggableListController.php index 91a1dce..c606a47 100644 --- a/core/lib/Drupal/Core/Config/Entity/DraggableListController.php +++ b/core/lib/Drupal/Core/Config/Entity/DraggableListController.php @@ -10,7 +10,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormInterface; /** @@ -49,8 +48,8 @@ /** * {@inheritdoc} */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage) { + parent::__construct($entity_info, $storage); // Check if the entity type supports weighting. if ($this->entityInfo->hasKey('weight')) { diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php index f6055ab..a0dc9ea 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php @@ -62,13 +62,12 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = public function resetCache(); /** - * Sets the module handler for this form. + * Sets the module handler for this access controller. * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. * - * @return self - * The entity access controller. + * @return static */ public function setModuleHandler(ModuleHandlerInterface $module_handler); diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index fdbc6a9..b425769 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -7,7 +7,6 @@ namespace Drupal\Core\Entity; -use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\StringTranslation\TranslationInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -59,8 +58,7 @@ class EntityListController implements EntityListControllerInterface, EntityContr public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) { return new static( $entity_info, - $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler') + $container->get('entity.manager')->getStorageController($entity_info->id()) ); } @@ -71,14 +69,11 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler) { + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage) { $this->entityType = $entity_info->id(); $this->storage = $storage; $this->entityInfo = $entity_info; - $this->moduleHandler = $module_handler; } /** @@ -216,30 +211,16 @@ public function render() { * 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->translationManager->translate($string, $args, $options); } /** - * Gets the translation manager. - * - * @return \Drupal\Core\StringTranslation\TranslationInterface - * The translation manager. - */ - protected function translationManager() { - if (!$this->translationManager) { - $this->translationManager = \Drupal::translation(); - } - return $this->translationManager; - } - - /** - * Sets the translation manager for this form. + * Sets the translation manager for this list. * * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager * The translation manager. * - * @return self - * The entity form. + * @return static */ public function setTranslationManager(TranslationInterface $translation_manager) { $this->translationManager = $translation_manager; @@ -247,6 +228,19 @@ public function setTranslationManager(TranslationInterface $translation_manager) } /** + * Sets the module handler for this list. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + * + * @return static + */ + public function setModuleHandler(ModuleHandlerInterface $module_handler) { + $this->moduleHandler = $module_handler; + return $this; + } + + /** * Returns the title of the page. * * @return string diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index e590d64..ad78252 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -159,6 +159,20 @@ public function clearCachedDefinitions() { /** * {@inheritdoc} */ + public function getDefinition($entity_type_id, $exception_on_invalid = FALSE) { + if ($entity_type = parent::getDefinition($entity_type_id)) { + return $entity_type; + } + elseif (!$exception_on_invalid) { + return NULL; + } + + throw new \InvalidArgumentException(sprintf('The "%s" entity type does not exist.', $entity_type_id)); + } + + /** + * {@inheritdoc} + */ public function hasController($entity_type, $controller_type) { if ($definition = $this->getDefinition($entity_type)) { return $definition->hasController($controller_type); @@ -169,55 +183,15 @@ public function hasController($entity_type, $controller_type) { /** * {@inheritdoc} */ - public function getControllerClass($entity_type, $controller_type, $nested = NULL) { - $info = $this->getDefinition($entity_type); - if (!$info) { - throw new \InvalidArgumentException(sprintf('The %s entity type does not exist.', $entity_type)); - } - - if (!$info->hasController($controller_type)) { - throw new \InvalidArgumentException(sprintf('The entity type (%s) did not specify a %s controller.', $entity_type, $controller_type)); - } - - $class = $info->getController($controller_type); - - // Some class definitions can be nested. - if (isset($nested)) { - if (empty($class[$nested])) { - throw new \InvalidArgumentException(sprintf("The entity type (%s) did not specify a %s controller: %s.", $entity_type, $controller_type, $nested)); - } - - $class = $class[$nested]; - } - - if (!class_exists($class)) { - throw new \InvalidArgumentException(sprintf('The entity type (%s) %s controller "%s" does not exist.', $entity_type, $controller_type, $class)); - } - - return $class; - } - - /** - * {@inheritdoc} - */ public function getStorageController($entity_type) { - return $this->getController($entity_type, 'storage'); + return $this->getController($entity_type, 'storage', 'getStorage'); } /** * {@inheritdoc} */ public function getListController($entity_type) { - if (!isset($this->controllers['listing'][$entity_type])) { - $class = $this->getControllerClass($entity_type, 'list'); - if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { - $this->controllers['listing'][$entity_type] = $class::createInstance($this->container, $this->getDefinition($entity_type)); - } - else { - $this->controllers['listing'][$entity_type] = new $class($entity_type, $this->getStorageController($entity_type)); - } - } - return $this->controllers['listing'][$entity_type]; + return $this->getController($entity_type, 'list', 'getList'); } /** @@ -225,7 +199,9 @@ public function getListController($entity_type) { */ public function getFormController($entity_type, $operation) { if (!isset($this->controllers['form'][$operation][$entity_type])) { - $class = $this->getControllerClass($entity_type, 'form', $operation); + if (!$class = $this->getDefinition($entity_type, TRUE)->getForm($operation)) { + throw new \InvalidArgumentException(sprintf('The "%s" entity type did not specify a "%s" form class.', $entity_type, $operation)); + } if (in_array('Drupal\Core\DependencyInjection\ContainerInjectionInterface', class_implements($class))) { $controller = $class::create($this->container); } @@ -246,40 +222,44 @@ public function getFormController($entity_type, $operation) { * {@inheritdoc} */ public function getViewBuilder($entity_type) { - return $this->getController($entity_type, 'view_builder'); + return $this->getController($entity_type, 'view_builder', 'getViewBuilder'); } /** * {@inheritdoc} */ public function getAccessController($entity_type) { - if (!isset($this->controllers['access'][$entity_type])) { - $controller = $this->getController($entity_type, 'access'); - $controller->setModuleHandler($this->moduleHandler); - } - return $this->controllers['access'][$entity_type]; + return $this->getController($entity_type, 'access', 'getAccess'); } /** - * Creates a new controller instance. - * - * @param string $entity_type - * The entity type for this access controller. - * @param string $controller_type - * The controller type to create an instance for. - * - * @return mixed. - * A controller instance. + * {@inheritdoc} */ - protected function getController($entity_type, $controller_type) { + public function getController($entity_type, $controller_type, $controller_getter = NULL) { if (!isset($this->controllers[$controller_type][$entity_type])) { - $class = $this->getControllerClass($entity_type, $controller_type); - if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { - $this->controllers[$controller_type][$entity_type] = $class::createInstance($this->container, $this->getDefinition($entity_type)); + $definition = $this->getDefinition($entity_type, TRUE); + if ($controller_getter) { + $class = $definition->{$controller_getter}(); } else { - $this->controllers[$controller_type][$entity_type] = new $class($this->getDefinition($entity_type)); + $class = $definition->getController($controller_type); } + if (!$class) { + throw new \InvalidArgumentException(sprintf('The "%s" entity type did not specify a %s class.', $entity_type, $controller_type)); + } + if (is_subclass_of($class, 'Drupal\Core\Entity\EntityControllerInterface')) { + $controller = $class::createInstance($this->container, $definition); + } + else { + $controller = new $class($definition); + } + if (method_exists($controller, 'setModuleHandler')) { + $controller->setModuleHandler($this->moduleHandler); + } + if (method_exists($controller, 'setTranslationManager')) { + $controller->setTranslationManager($this->translationManager); + } + $this->controllers[$controller_type][$entity_type] = $controller; } return $this->controllers[$controller_type][$entity_type]; } diff --git a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php index cb962e0..98de0f9 100644 --- a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php @@ -105,22 +105,6 @@ public function getFieldDefinitionsByConstraints($entity_type, array $constraint public function getStorageController($entity_type); /** - * Returns an entity controller class. - * - * @param string $entity_type - * The name of the entity type - * @param string $controller_type - * The name of the controller. - * @param string|null $nested - * (optional) If this controller definition is nested, the name of the key. - * Defaults to NULL. - * - * @return string - * The class name for this controller instance. - */ - public function getControllerClass($entity_type, $controller_type, $nested = NULL); - - /** * Get the bundle info of all entity types. * * @return array @@ -205,6 +189,23 @@ public function clearCachedFieldDefinitions(); public function hasController($entity_type, $controller_type); /** + * Creates a new controller instance. + * + * @param string $entity_type + * The entity type for this controller. + * @param string $controller_type + * The controller type to create an instance for. + * @param string $controller_getter + * (optional) The method to call on the entity type object to get the controller class. + * + * @return mixed + * A controller instance. + * + * @throws \InvalidArgumentException + */ + public function getController($entity_type, $controller_type, $controller_getter = NULL); + + /** * Returns the built and processed entity form for the given entity. * * @param \Drupal\Core\Entity\EntityInterface $entity @@ -265,13 +266,20 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N /** * Returns the entity type info for a specific entity type. * - * @param string $entity_type_name - * The name of the entity type. + * @param string $entity_type_id + * The ID of the entity type. + * @param bool $exception_on_invalid + * (optional) If TRUE, an invalid entity type ID will throw an exception. + * Defaults to FALSE. * * @return \Drupal\Core\Entity\EntityTypeInterface|null - * Either the entity type object, or NULL if the name does not exist. + * Returns the entity type object, or NULL if the entity type ID is invalid + * and $exception_on_invalid is TRUE. + * + * @throws \InvalidArgumentException + * Thrown if $entity_type_id is invalid and $exception_on_invalid is TRUE. */ - public function getDefinition($entity_type_name); + public function getDefinition($entity_type_id, $exception_on_invalid = FALSE); /** * Returns an array of entity type info, keyed by entity type name. diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php index 8774ac2..2a0adf8 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Entity; use Drupal\Core\Entity\Query\QueryInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; /** * A base entity storage controller class. @@ -44,6 +45,13 @@ protected $entityInfo; /** + * The module handler to invoke hooks on. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** * Name of the entity's ID field in the entity database table. * * @var string @@ -149,9 +157,9 @@ protected function cacheSet($entities) { */ protected function invokeHook($hook, EntityInterface $entity) { // Invoke the hook. - module_invoke_all($this->entityType . '_' . $hook, $entity); + $this->moduleHandler->invokeAll($this->entityType . '_' . $hook, array($entity)); // Invoke the respective entity-level hook. - module_invoke_all('entity_' . $hook, $entity, $this->entityType); + $this->moduleHandler->invokeAll('entity_' . $hook, array($entity, $this->entityType)); } /** @@ -164,12 +172,12 @@ protected function postLoad(array &$queried_entities) { $entity_class = $this->entityInfo->getClass(); $entity_class::postLoad($this, $queried_entities); // Call hook_entity_load(). - foreach (\Drupal::moduleHandler()->getImplementations('entity_load') as $module) { + foreach ($this->moduleHandler->getImplementations('entity_load') as $module) { $function = $module . '_entity_load'; $function($queried_entities, $this->entityType); } // Call hook_TYPE_load(). - foreach (\Drupal::moduleHandler()->getImplementations($this->entityType . '_load') as $module) { + foreach ($this->moduleHandler->getImplementations($this->entityType . '_load') as $module) { $function = $module . '_' . $this->entityType . '_load'; $function($queried_entities); } @@ -201,4 +209,17 @@ public function loadByProperties(array $values = array()) { return $result ? $this->loadMultiple($result) : array(); } + /** + * Sets the module handler for this storage. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + * + * @return static + */ + public function setModuleHandler(ModuleHandlerInterface $module_handler) { + $this->moduleHandler = $module_handler; + return $this; + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 1d86e02..b552a3e 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -318,8 +318,12 @@ public function getControllers() { * {@inheritdoc} */ public function getController($controller_type) { - $controllers = $this->getControllers(); - return $controllers[$controller_type]; + if ($this->hasController($controller_type)) { + $controllers = $this->getControllers(); + return $controllers[$controller_type]; + } + + return ''; } /** @@ -335,7 +339,29 @@ public function setController($controller_type, $value) { */ public function hasController($controller_type) { $controllers = $this->getControllers(); - return isset($controllers[$controller_type]); + return isset($controllers[$controller_type]) && class_exists($controllers[$controller_type]); + } + + /** + * {@inheritdoc} + */ + public function getStorage() { + return $this->getController('storage'); + } + + /** + * {@inheritdoc} + */ + public function setStorage($class) { + $this->controllers['storage'] = $class; + } + + /** + * {@inheritdoc} + */ + public function getForm($operation) { + $forms = $this->getController('form'); + return $forms[$operation]; } /** @@ -349,6 +375,13 @@ public function setForm($operation, $class) { /** * {@inheritdoc} */ + public function getList() { + return $this->getController('list'); + } + + /** + * {@inheritdoc} + */ public function setList($class) { $this->controllers['list'] = $class; return $this; @@ -357,6 +390,36 @@ public function setList($class) { /** * {@inheritdoc} */ + public function getViewBuilder() { + return $this->getController('view_builder'); + } + + /** + * {@inheritdoc} + */ + public function setViewBuilder($class) { + $this->controllers['view_builder'] = $class; + return $this; + } + + /** + * {@inheritdoc} + */ + public function getAccess() { + return $this->getController('access'); + } + + /** + * {@inheritdoc} + */ + public function setAccess($class) { + $this->controllers['access'] = $class; + return $this; + } + + /** + * {@inheritdoc} + */ public function getAdminPermission() { return $this->admin_permission ?: FALSE; } diff --git a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php index 4cb05aa..99cb9ac 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -202,6 +202,35 @@ public function getController($controller_type); public function getControllers(); /** + * Returns the storage class. + * + * @return string + * The class for this entity type's storage. + */ + public function getStorage(); + + /** + * Sets the storage class. + * + * @param string $class + * The class for this entity type's storage. + * + * @return static + */ + public function setStorage($class); + + /** + * Returns the form class for a specific operation. + * + * @param string $operation + * The name of the operation to use, e.g., 'default'. + * + * @return string + * The class for this operation's form for this entity type. + */ + public function getForm($operation); + + /** * Sets a form class for a specific operation. * * @param string $operation @@ -214,6 +243,14 @@ public function getControllers(); public function setForm($operation, $class); /** + * Returns the list class. + * + * @return string + * The class for this entity type's list. + */ + public function getList(); + + /** * Sets the listing class. * * @param string $class @@ -224,6 +261,42 @@ public function setForm($operation, $class); public function setList($class); /** + * Returns the view builder class. + * + * @return string + * The class for this entity type's view builder. + */ + public function getViewBuilder(); + + /** + * Returns the view builder class. + * + * @param string $class + * The class for this entity type's view builder. + * + * @return static + */ + public function setViewBuilder($class); + + /** + * Returns the access class. + * + * @return string + * The class for this entity type's access. + */ + public function getAccess(); + + /** + * Returns the access class. + * + * @param string $class + * The class for this entity type's access. + * + * @return static + */ + public function setAccess($class); + + /** * Indicates if the entity type is a subclass of the given class or interface. * * @param string $class diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index 1f09b3b..28dc4f5 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Entity; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\Language; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -38,6 +39,13 @@ class EntityViewBuilder implements EntityControllerInterface, EntityViewBuilderI protected $entityManager; /** + * The module handler to invoke hooks on. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** * The cache bin used to store the render cache. * * @todo Defaults to 'cache' for now, until http://drupal.org/node/1194136 is @@ -273,4 +281,17 @@ protected function isViewModeCacheable($view_mode) { return !empty($view_modes_info[$view_mode]['cache']); } + /** + * Sets the module handler for this view builder. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + * + * @return static + */ + public function setModuleHandler(ModuleHandlerInterface $module_handler) { + $this->moduleHandler = $module_handler; + return $this; + } + } diff --git a/core/modules/action/lib/Drupal/action/ActionListController.php b/core/modules/action/lib/Drupal/action/ActionListController.php index 03f7b75..ee612c9 100644 --- a/core/modules/action/lib/Drupal/action/ActionListController.php +++ b/core/modules/action/lib/Drupal/action/ActionListController.php @@ -13,7 +13,6 @@ use Drupal\Core\Config\Entity\ConfigEntityListController; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -42,11 +41,9 @@ class ActionListController extends ConfigEntityListController implements EntityC * The action storage controller. * @param \Drupal\Core\Action\ActionManager $action_manager * The action plugin manager. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ActionManager $action_manager, ModuleHandlerInterface $module_handler) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ActionManager $action_manager) { + parent::__construct($entity_info, $storage); $this->actionManager = $action_manager; } @@ -58,8 +55,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('plugin.manager.action'), - $container->get('module_handler') + $container->get('plugin.manager.action') ); } diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 8547ba4..c440378 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -60,13 +60,11 @@ class BlockListController extends ConfigEntityListController implements FormInte * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Component\Plugin\PluginManagerInterface $block_manager * The block manager. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, PluginManagerInterface $block_manager) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, PluginManagerInterface $block_manager) { + parent::__construct($entity_info, $storage); $this->blockManager = $block_manager; } @@ -78,7 +76,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler'), $container->get('plugin.manager.block') ); } diff --git a/core/modules/block/lib/Drupal/block/BlockViewBuilder.php b/core/modules/block/lib/Drupal/block/BlockViewBuilder.php index 5aed185..105fcb1 100644 --- a/core/modules/block/lib/Drupal/block/BlockViewBuilder.php +++ b/core/modules/block/lib/Drupal/block/BlockViewBuilder.php @@ -7,13 +7,14 @@ namespace Drupal\block; +use Drupal\Core\Entity\EntityViewBuilder; use Drupal\Core\Entity\EntityViewBuilderInterface; use Drupal\Core\Entity\EntityInterface; /** * Provides a Block view builder. */ -class BlockViewBuilder implements EntityViewBuilderInterface { +class BlockViewBuilder extends EntityViewBuilder { /** * {@inheritdoc} @@ -57,7 +58,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la $build[$entity_id] = array(); } - drupal_alter(array('block_view', "block_view_$base_id"), $build[$entity_id], $plugin); + $this->moduleHandler->alter(array('block_view', "block_view_$base_id"), $build[$entity_id], $plugin); // @todo Remove after fixing http://drupal.org/node/1989568. $build[$entity_id]['#block'] = $entity; diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index 7dd6517..9c0257d 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -8,13 +8,10 @@ namespace Drupal\comment; use Drupal\Core\Access\CsrfTokenGenerator; -use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\EntityViewBuilderInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Entity\EntityViewBuilder; use Drupal\field\FieldInfo; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -22,7 +19,7 @@ /** * Render controller for comments. */ -class CommentViewBuilder extends EntityViewBuilder implements EntityViewBuilderInterface, EntityControllerInterface { +class CommentViewBuilder extends EntityViewBuilder { /** * The field info service. @@ -53,7 +50,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_info, $container->get('entity.manager'), $container->get('field.info'), - $container->get('module_handler'), $container->get('csrf_token') ); } @@ -67,15 +63,12 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * The entity manager service. * @param \Drupal\field\FieldInfo $field_info * The field info service. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler service. * @param \Drupal\Core\Access\CsrfTokenGenerator $csrf_token * The CSRF token manager service. */ - public function __construct(EntityTypeInterface $entity_info, EntityManagerInterface $entity_manager, FieldInfo $field_info, ModuleHandlerInterface $module_handler, CsrfTokenGenerator $csrf_token) { + public function __construct(EntityTypeInterface $entity_info, EntityManagerInterface $entity_manager, FieldInfo $field_info, CsrfTokenGenerator $csrf_token) { parent::__construct($entity_info, $entity_manager); $this->fieldInfo = $field_info; - $this->moduleHandler = $module_handler; $this->csrfToken = $csrf_token; } diff --git a/core/modules/config_translation/config_translation.api.php b/core/modules/config_translation/config_translation.api.php index aa1f7f0..c9e6656 100644 --- a/core/modules/config_translation/config_translation.api.php +++ b/core/modules/config_translation/config_translation.api.php @@ -56,7 +56,6 @@ function hook_config_translation_info(&$info) { 'title' => t('!label field'), 'class' => '\Drupal\config_translation\ConfigFieldInstanceMapper', 'base_entity_type' => $entity_type, - 'list_controller' => '\Drupal\config_translation\Controller\ConfigTranslationFieldInstanceListController', 'weight' => 10, ); } diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index 33a2ee7..fdb66f6 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -70,6 +70,25 @@ function config_translation_theme() { } /** + * Implements hook_entity_info(). + */ +function config_translation_entity_info($entity_info) { + /** @var $entity_info \Drupal\Core\Entity\EntityTypeInterface[] */ + foreach ($entity_info as $entity_type_id => $entity_type) { + if ($entity_type_id == 'block') { + $class = 'Drupal\config_translation\Controller\ConfigTranslationBlockListController'; + } + elseif ($entity_type_id == 'field_instance') { + $class = 'Drupal\config_translation\Controller\ConfigTranslationFieldInstanceListController'; + } + else { + $class = 'Drupal\config_translation\Controller\ConfigTranslationEntityListController'; + } + $entity_type->setController('config_translation_list', $class); + } +} + +/** * Implements hook_config_translation_info(). */ function config_translation_config_translation_info(&$info) { @@ -97,7 +116,6 @@ function config_translation_config_translation_info(&$info) { 'title' => '!label field', 'class' => '\Drupal\config_translation\ConfigFieldInstanceMapper', 'base_entity_type' => $entity_type, - 'list_controller' => '\Drupal\config_translation\Controller\ConfigTranslationFieldInstanceListController', 'weight' => 10, ); } @@ -128,11 +146,6 @@ function config_translation_config_translation_info(&$info) { 'entity_type' => $entity_type, 'weight' => 10, ); - - if ($entity_type == 'block') { - // Blocks placements need a specific list controller. - $info['block']['list_controller'] = '\Drupal\config_translation\Controller\ConfigTranslationBlockListController'; - } } } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php index edb431c..d787c14 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/ConfigMapperManager.php @@ -41,7 +41,6 @@ class ConfigMapperManager extends DefaultPluginManager implements ConfigMapperMa 'names' => array(), 'weight' => 20, 'class' => '\Drupal\config_translation\ConfigNamesMapper', - 'list_controller' => 'Drupal\config_translation\Controller\ConfigTranslationEntityListController', ); /** @@ -119,10 +118,6 @@ public function processDefinition(&$definition, $plugin_id) { if (!isset($definition['base_route_name'])) { throw new InvalidMapperDefinitionException($plugin_id, String::format("The plugin definition of the mapper '%plugin_id' does not contain a base_route_name.", array('%plugin_id' => $plugin_id))); } - - if (!is_subclass_of($definition['list_controller'], 'Drupal\config_translation\Controller\ConfigTranslationEntityListControllerInterface')) { - throw new InvalidMapperDefinitionException($plugin_id, String::format("The list_controller '%list_controller' for plugin '%plugin_id' does not implement the expected interface Drupal\config_translation\Controller\ConfigTranslationEntityListControllerInterface.", array('%list_controller' => $definition['list_controller'], '%plugin_id' => $plugin_id))); - } } /** diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationBlockListController.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationBlockListController.php index 35c10cc..5ccd65a 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationBlockListController.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationBlockListController.php @@ -11,7 +11,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Defines the config translation controller for blocks. @@ -28,9 +28,20 @@ class ConfigTranslationBlockListController extends ConfigTranslationEntityListCo /** * {@inheritdoc} */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler) { - parent::__construct($entity_info, $storage, $module_handler); - $this->themes = list_themes(); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, array $themes) { + parent::__construct($entity_info, $storage); + $this->themes = $themes; + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) { + return new static( + $entity_info, + $container->get('entity.manager')->getStorageController($entity_info->id()), + $container->get('theme_handler')->listInfo() + ); } /** diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListController.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListController.php index 09a9de6..8c09840 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListController.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListController.php @@ -127,4 +127,12 @@ protected function sortRowsMultiple($a, $b, $keys) { return strnatcasecmp($a_value, $b_value); } + /** + * {@inheritdoc} + */ + public function setMapperDefinition($mapper_definition) { + // @todo Why is this method called on all config list controllers? + return $this; + } + } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListControllerInterface.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListControllerInterface.php index d342808..3e5032a 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListControllerInterface.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationEntityListControllerInterface.php @@ -27,4 +27,14 @@ */ public function sortRows($a, $b); + /** + * Sets the config translation mapper definition. + * + * @param mixed $mapper_definition + * The plugin definition of the config translation mapper. + * + * @return static + */ + public function setMapperDefinition($mapper_definition); + } diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListController.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListController.php index 2f8630a..736aee9 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListController.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationFieldInstanceListController.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\field\Field; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -51,25 +50,14 @@ class ConfigTranslationFieldInstanceListController extends ConfigTranslationEnti protected $entityManager; /** - * Instantiates a new instance of this entity controller. - * - * @param \Symfony\Component\DependencyInjection\ContainerInterface $container - * The service container this object should use. - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info - * The entity info for the entity type. - * @param array $definition - * (optional) The plugin definition of the config translation mapper. - * - * @return static - * A new instance of the entity controller. + * {@inheritdoc} */ - public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info, array $definition = array()) { + public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) { + $entity_manager = $container->get('entity.manager'); return new static( $entity_info, - $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler'), - $container->get('entity.manager'), - $definition + $entity_manager->getStorageController($entity_info->id()), + $entity_manager ); } @@ -80,19 +68,22 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param array $definition - * The plugin definition of the config translation mapper. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager, array $definition) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, EntityManagerInterface $entity_manager) { + parent::__construct($entity_info, $storage); $this->entityManager = $entity_manager; - $this->baseEntityType = $definition['base_entity_type']; + } + + /** + * {@inheritdoc} + */ + public function setMapperDefinition($mapper_definition) { + $this->baseEntityType = $mapper_definition['base_entity_type']; $this->baseEntityInfo = $this->entityManager->getDefinition($this->baseEntityType); $this->baseEntityBundles = $this->entityManager->getBundleInfo($this->baseEntityType); + return $this; } /** 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 14bd763..e8bdad3 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 @@ -74,10 +74,10 @@ public function listing() { // list controller defined, use it. Other mappers, for examples the ones for // node_type and block, fallback to the generic configuration translation // list controller. - $class = $this->mapperDefinition['list_controller']; - /** @var \Drupal\config_translation\Controller\ConfigTranslationEntityListControllerInterface $controller */ - $controller = new $class($this->entityManager()->getDefinition($entity_type), $this->entityManager()->getStorageController($entity_type), $this->moduleHandler(), $this->entityManager(), $this->mapperDefinition); - $build = $controller->render(); + $build = $this->entityManager() + ->getController($entity_type, 'config_translation_list') + ->setMapperDefinition($this->mapperDefinition) + ->render(); $build['#title'] = $this->mapper->getTypeLabel(); return $build; } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php index 7bf8ea0..89d03b8 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php @@ -44,8 +44,7 @@ public function access(Route $route, Request $request, AccountInterface $account if ($entity = $request->attributes->get($entity_type)) { $route_requirements = $route->getRequirements(); $operation = $route_requirements['_access_content_translation_manage']; - $controller_class = $this->entityManager->getControllerClass($entity_type, 'translation'); - $controller = new $controller_class($entity->entityInfo()); + $controller = content_translation_controller($entity_type); // Load translation. $translations = $entity->getTranslationLanguages(); diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php index 8946534..7f18505 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -33,13 +32,11 @@ class EntityDisplayModeListController extends ConfigEntityListController { * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_info_complete * The entity info for all entity types. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, array $entity_info_complete) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, array $entity_info_complete) { + parent::__construct($entity_info, $storage); $this->entityInfoComplete = $entity_info_complete; } @@ -52,7 +49,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $entity_manager->getStorageController($entity_info->id()), - $container->get('module_handler'), $entity_manager->getDefinitions() ); } diff --git a/core/modules/field/field.views.inc b/core/modules/field/field.views.inc index e9e65c4..172aee4 100644 --- a/core/modules/field/field.views.inc +++ b/core/modules/field/field.views.inc @@ -67,13 +67,8 @@ function field_views_data_alter(&$data) { */ function _field_views_is_sql_entity_type(FieldInterface $field) { $entity_manager = \Drupal::entityManager(); - try { - if ($entity_manager->getStorageController($field->entity_type) instanceof FieldableDatabaseStorageController) { - return TRUE; - } - } - catch (\InvalidArgumentException $e) { - // Disabled entity type, nothing to do. + if ($entity_manager->getDefinition($field->entity_type) && $entity_manager->getStorageController($field->entity_type) instanceof FieldableDatabaseStorageController) { + return TRUE; } } diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php index ef25a51..be9b370 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php @@ -30,13 +30,6 @@ class FieldInstanceStorageController extends ConfigStorageController { /** - * The module handler. - * - * @var \Drupal\Core\Extension\ModuleHandler - */ - protected $moduleHandler; - - /** * The entity manager. * * @var \Drupal\Core\Entity\EntityManagerInterface @@ -65,15 +58,12 @@ class FieldInstanceStorageController extends ConfigStorageController { * The UUID service. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Extension\ModuleHandler $module_handler - * The module handler. * @param \Drupal\Core\KeyValueStore\StateInterface $state * The state key value store. */ - public function __construct(EntityTypeInterface $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, ModuleHandler $module_handler, StateInterface $state) { + public function __construct(EntityTypeInterface $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service, EntityManagerInterface $entity_manager, StateInterface $state) { parent::__construct($entity_info, $config_factory, $config_storage, $entity_query_factory, $uuid_service); $this->entityManager = $entity_manager; - $this->moduleHandler = $module_handler; $this->state = $state; } @@ -88,7 +78,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $container->get('entity.query'), $container->get('uuid'), $container->get('entity.manager'), - $container->get('module_handler'), $container->get('state') ); } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php index 76efe54..8cc0228 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php @@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldTypePluginManager; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -55,13 +54,11 @@ class FieldListController extends ConfigEntityListController { * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager * The 'field type' plugin manager. */ - public function __construct(EntityTypeInterface $entity_info, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, FieldTypePluginManager $field_type_manager) { - parent::__construct($entity_info, $entity_manager->getStorageController($entity_info->id()), $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager) { + parent::__construct($entity_info, $entity_manager->getStorageController($entity_info->id())); $this->entityManager = $entity_manager; $this->bundles = entity_get_bundles(); @@ -76,7 +73,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('entity.manager'), - $container->get('module_handler'), $container->get('plugin.manager.field.field_type') ); } diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php index e01e26b..3b70aea 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php @@ -14,7 +14,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -41,13 +40,11 @@ class FilterFormatListController extends DraggableListController implements Enti * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, ConfigFactory $config_factory) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ConfigFactory $config_factory) { + parent::__construct($entity_info, $storage); $this->configFactory = $config_factory; } @@ -59,7 +56,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler'), $container->get('config.factory') ); } diff --git a/core/modules/image/lib/Drupal/image/ImageStyleListController.php b/core/modules/image/lib/Drupal/image/ImageStyleListController.php index bf5618b..cce8dcf 100644 --- a/core/modules/image/lib/Drupal/image/ImageStyleListController.php +++ b/core/modules/image/lib/Drupal/image/ImageStyleListController.php @@ -12,7 +12,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\StringTranslation\Translator\TranslatorInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -36,13 +35,11 @@ class ImageStyleListController extends ConfigEntityListController implements Ent * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $image_style_storage * The image style entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator * The URL generator. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $image_style_storage, ModuleHandlerInterface $module_handler, UrlGeneratorInterface $url_generator) { - parent::__construct($entity_info, $image_style_storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $image_style_storage, UrlGeneratorInterface $url_generator) { + parent::__construct($entity_info, $image_style_storage); $this->urlGenerator = $url_generator; } @@ -53,7 +50,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler'), $container->get('url_generator'), $container->get('string_translation') ); diff --git a/core/modules/node/lib/Drupal/node/NodeListController.php b/core/modules/node/lib/Drupal/node/NodeListController.php index 8d488ca..f8e2f65 100644 --- a/core/modules/node/lib/Drupal/node/NodeListController.php +++ b/core/modules/node/lib/Drupal/node/NodeListController.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityListController; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\Language; use Drupal\Core\StringTranslation\TranslationInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -37,13 +36,11 @@ class NodeListController extends EntityListController { * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Datetime\Date $date_service * The date service. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, Date $date_service) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, Date $date_service) { + parent::__construct($entity_info, $storage); $this->dateService = $date_service; } @@ -55,7 +52,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler'), $container->get('date') ); } diff --git a/core/modules/node/lib/Drupal/node/NodeTypeListController.php b/core/modules/node/lib/Drupal/node/NodeTypeListController.php index 813f6ca..1549b8f 100644 --- a/core/modules/node/lib/Drupal/node/NodeTypeListController.php +++ b/core/modules/node/lib/Drupal/node/NodeTypeListController.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityTypeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Component\Utility\Xss; @@ -36,13 +35,11 @@ class NodeTypeListController extends ConfigEntityListController implements Entit * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator * The url generator service. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, UrlGeneratorInterface $url_generator) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, UrlGeneratorInterface $url_generator) { + parent::__construct($entity_info, $storage); $this->urlGenerator = $url_generator; } @@ -53,7 +50,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler'), $container->get('url_generator') ); } diff --git a/core/modules/search/lib/Drupal/search/SearchPageListController.php b/core/modules/search/lib/Drupal/search/SearchPageListController.php index 6f86728..e7a7d8b 100644 --- a/core/modules/search/lib/Drupal/search/SearchPageListController.php +++ b/core/modules/search/lib/Drupal/search/SearchPageListController.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -52,13 +51,11 @@ class SearchPageListController extends DraggableListController implements FormIn * The entity storage controller class. * @param \Drupal\search\SearchPluginManager $search_manager * The search plugin manager. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Config\ConfigFactory $config_factory * The factory for configuration objects. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, SearchPluginManager $search_manager, ModuleHandlerInterface $module_handler, ConfigFactory $config_factory) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, SearchPluginManager $search_manager, ConfigFactory $config_factory) { + parent::__construct($entity_info, $storage); $this->configFactory = $config_factory; $this->searchManager = $search_manager; } @@ -71,7 +68,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_info, $container->get('entity.manager')->getStorageController($entity_info->id()), $container->get('plugin.manager.search'), - $container->get('module_handler'), $container->get('config.factory') ); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php index 8568672..715325a 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Tests/DrupalUnitTestBaseTest.php @@ -199,7 +199,7 @@ function testInstallConfig() { */ function testEnableModulesFixedList() { // Install system module. - $this->container->get('module_handler')->install(array('system')); + $this->container->get('module_handler')->install(array('system', 'menu_link')); $entity_manager = \Drupal::entityManager(); // entity_test is loaded via $modules; its entity type should exist. diff --git a/core/modules/system/lib/Drupal/system/DateFormatListController.php b/core/modules/system/lib/Drupal/system/DateFormatListController.php index 673730d..85d63d9 100644 --- a/core/modules/system/lib/Drupal/system/DateFormatListController.php +++ b/core/modules/system/lib/Drupal/system/DateFormatListController.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -35,13 +34,11 @@ class DateFormatListController extends ConfigEntityListController { * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Datetime\Date $date_service * The date service. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, Date $date_service) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, Date $date_service) { + parent::__construct($entity_info, $storage); $this->dateService = $date_service; } @@ -53,7 +50,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler'), $container->get('date') ); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php index cb5ba0c..9b0295a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityApiInfoTest.php @@ -54,6 +54,6 @@ function testEntityInfoCacheWatchdog() { \Drupal::moduleHandler()->install(array('entity_cache_test')); $info = \Drupal::state()->get('entity_cache_test'); $this->assertEqual($info->getLabel(), 'Entity Cache Test', 'Entity info label is correct.'); - $this->assertEqual($info->getController('storage'), 'Drupal\Core\Entity\DatabaseStorageController', 'Entity controller class info is correct.'); + $this->assertEqual($info->getStorage(), 'Drupal\Core\Entity\DatabaseStorageController', 'Entity controller class info is correct.'); } } diff --git a/core/modules/user/lib/Drupal/user/Controller/UserListController.php b/core/modules/user/lib/Drupal/user/Controller/UserListController.php index 4d2a406..a928b55 100644 --- a/core/modules/user/lib/Drupal/user/Controller/UserListController.php +++ b/core/modules/user/lib/Drupal/user/Controller/UserListController.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\Query\QueryFactory; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -37,13 +36,11 @@ class UserListController extends EntityListController implements EntityControlle * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage * The entity storage controller class. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler to invoke hooks on. * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query factory. */ - public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, ModuleHandlerInterface $module_handler, QueryFactory $query_factory) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, QueryFactory $query_factory) { + parent::__construct($entity_info, $storage); $this->queryFactory = $query_factory; } @@ -54,7 +51,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_info, $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler'), $container->get('entity.query') ); } diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php index b0d830b..b260a74 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayPageTest.php @@ -33,7 +33,7 @@ class DisplayPageTest extends ViewUnitTestBase { * * @var array */ - public static $modules = array('system', 'user', 'menu_link', 'field'); + public static $modules = array('system', 'user', 'menu_link', 'field', 'entity'); /** * The router dumper to get all routes. diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php index b45efe7..363a285 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php @@ -14,7 +14,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -34,27 +33,24 @@ class ViewListController extends ConfigEntityListController implements EntityCon */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) { return new static( - $container->get('entity.manager')->getStorageController($entity_info->id()), $entity_info, - $container->get('plugin.manager.views.display'), - $container->get('module_handler') + $container->get('entity.manager')->getStorageController($entity_info->id()), + $container->get('plugin.manager.views.display') ); } /** * Constructs a new EntityListController object. * - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage. - * The entity storage controller class. * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * An array of entity info for this entity type. + * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage. + * The entity storage controller class. * @param \Drupal\Component\Plugin\PluginManagerInterface $display_manager * The views display plugin manager to use. - * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler - * The module handler. */ - public function __construct(EntityStorageControllerInterface $storage, EntityTypeInterface $entity_info, PluginManagerInterface $display_manager, ModuleHandlerInterface $module_handler) { - parent::__construct($entity_info, $storage, $module_handler); + public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, PluginManagerInterface $display_manager) { + parent::__construct($entity_info, $storage); $this->displayManager = $display_manager; } diff --git a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php index d058288..eaa5066 100644 --- a/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php +++ b/core/modules/views_ui/tests/Drupal/views_ui/Tests/ViewListControllerTest.php @@ -120,12 +120,10 @@ public function testBuildRowEntityList() { $container->set('string_translation', $this->getStringTranslationStub()); \Drupal::setContainer($container); - $module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); - // Setup a view list controller with a mocked buildOperations method, // because t() is called on there. $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); - $view_list_controller = $this->getMock('Drupal\views_ui\ViewListController', array('buildOperations'), array($storage_controller, $entity_type, $display_manager, $module_handler)); + $view_list_controller = $this->getMock('Drupal\views_ui\ViewListController', array('buildOperations'), array($entity_type, $storage_controller, $display_manager)); $view_list_controller->expects($this->any()) ->method('buildOperations') ->will($this->returnValue(array()));