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/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index fdbc6a9..9519a8e 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; } /** @@ -247,6 +242,14 @@ public function setTranslationManager(TranslationInterface $translation_manager) } /** + * {@inheritdoc} + */ + 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/EntityListControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityListControllerInterface.php index b7581d8..4cb4504 100644 --- a/core/lib/Drupal/Core/Entity/EntityListControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityListControllerInterface.php @@ -7,6 +7,9 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\StringTranslation\TranslationInterface; + /** * Defines an interface for entity list controllers. */ @@ -55,4 +58,26 @@ public function getOperations(EntityInterface $entity); */ public function render(); + /** + * Sets the translation manager for this form. + * + * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager + * The translation manager. + * + * @return self + * The entity form. + */ + public function setTranslationManager(TranslationInterface $translation_manager); + + /** + * Sets the module handler for this form. + * + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + * + * @return self + * The entity form. + */ + public function setModuleHandler(ModuleHandlerInterface $module_handler); + } diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index e590d64..316e0c6 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -169,39 +169,19 @@ 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)); + public function getStorageController($entity_type) { + if (!isset($this->controllers['storage'][$entity_type])) { + $definition = $this->getEntityTypeForReal($entity_type); + $class = $definition->getStorage(); + if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { + $controller = $class::createInstance($this->container, $definition); } - - $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)); + else { + $controller = new $class($definition); + } + $this->controllers['storage'][$entity_type] = $controller; } - - return $class; - } - - /** - * {@inheritdoc} - */ - public function getStorageController($entity_type) { - return $this->getController($entity_type, 'storage'); + return $this->controllers['storage'][$entity_type]; } /** @@ -209,13 +189,16 @@ public function getStorageController($entity_type) { */ public function getListController($entity_type) { if (!isset($this->controllers['listing'][$entity_type])) { - $class = $this->getControllerClass($entity_type, 'list'); + $definition = $this->getEntityTypeForReal($entity_type); + $class = $definition->getList(); if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { - $this->controllers['listing'][$entity_type] = $class::createInstance($this->container, $this->getDefinition($entity_type)); + $controller = $class::createInstance($this->container, $definition); } else { - $this->controllers['listing'][$entity_type] = new $class($entity_type, $this->getStorageController($entity_type)); + $controller = new $class($definition, $this->getStorageController($entity_type)); } + $controller->setModuleHandler($this->moduleHandler); + $this->controllers['listing'][$entity_type] = $controller; } return $this->controllers['listing'][$entity_type]; } @@ -225,7 +208,7 @@ 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); + $class = $this->getEntityTypeForReal($entity_type)->getForm($operation); if (in_array('Drupal\Core\DependencyInjection\ContainerInjectionInterface', class_implements($class))) { $controller = $class::create($this->container); } @@ -246,7 +229,18 @@ public function getFormController($entity_type, $operation) { * {@inheritdoc} */ public function getViewBuilder($entity_type) { - return $this->getController($entity_type, 'view_builder'); + if (!isset($this->controllers['view_builder'][$entity_type])) { + $definition = $this->getEntityTypeForReal($entity_type); + $class = $definition->getViewBuilder(); + if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { + $controller = $class::createInstance($this->container, $definition); + } + else { + $controller = new $class($definition); + } + $this->controllers['view_builder'][$entity_type] = $controller; + } + return $this->controllers['view_builder'][$entity_type]; } /** @@ -254,34 +248,37 @@ public function getViewBuilder($entity_type) { */ public function getAccessController($entity_type) { if (!isset($this->controllers['access'][$entity_type])) { - $controller = $this->getController($entity_type, 'access'); + $definition = $this->getEntityTypeForReal($entity_type); + $class = $definition->getAccess(); + if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { + $controller = $class::createInstance($this->container, $definition); + } + else { + $controller = new $class($definition); + } $controller->setModuleHandler($this->moduleHandler); + $this->controllers['access'][$entity_type] = $controller; } return $this->controllers['access'][$entity_type]; } /** - * Creates a new controller instance. + * Returns an entity type, or throws an exception if it doesn't exist. * - * @param string $entity_type - * The entity type for this access controller. - * @param string $controller_type - * The controller type to create an instance for. + * @param string $entity_type_id + * The entity type ID. * - * @return mixed. - * A controller instance. + * @return \Drupal\Core\Entity\EntityTypeInterface + * The entity type object. + * + * @throws \InvalidArgumentException */ - protected function getController($entity_type, $controller_type) { - 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)); - } - else { - $this->controllers[$controller_type][$entity_type] = new $class($this->getDefinition($entity_type)); - } + protected function getEntityTypeForReal($entity_type_id) { + if ($definition = $this->getDefinition($entity_type_id)) { + return $definition; } - return $this->controllers[$controller_type][$entity_type]; + + throw new \InvalidArgumentException(sprintf('The %s entity type does not exist.', $entity_type_id)); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php index cb962e0..c106539 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 diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 1d86e02..baef8d3 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -341,6 +341,42 @@ public function hasController($controller_type) { /** * {@inheritdoc} */ + public function getStorage() { + return $this->getController('storage'); + } + + /** + * {@inheritdoc} + */ + public function getForm($operation) { + $forms = $this->getController('form'); + return $forms[$operation]; + } + + /** + * {@inheritdoc} + */ + public function getList() { + return $this->getController('list'); + } + + /** + * {@inheritdoc} + */ + public function getViewBuilder() { + return $this->getController('view_builder'); + } + + /** + * {@inheritdoc} + */ + public function getAccess() { + return $this->getController('access'); + } + + /** + * {@inheritdoc} + */ public function setForm($operation, $class) { $this->controllers['form'][$operation] = $class; return $this; diff --git a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php index 4cb05aa..33bdb1c 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -202,6 +202,48 @@ public function getController($controller_type); public function getControllers(); /** + * @todo. + * + * @return \Drupal\Core\Entity\EntityStorageControllerInterface + */ + public function getStorage(); + + /** + * Creates a new form controller instance. + * + * @param string $operation + * The name of the operation to use, e.g., 'default'. + * + * @return \Drupal\Core\Entity\EntityFormControllerInterface + * A form controller instance. + */ + public function getForm($operation); + + /** + * Creates a new list controller instance. + * + * @return \Drupal\Core\Entity\EntityListControllerInterface + * A list controller instance. + */ + public function getList(); + + /** + * Creates a new view builder instance. + * + * @return \Drupal\Core\Entity\EntityViewBuilderInterface. + * A view builder instance. + */ + public function getViewBuilder(); + + /** + * Creates a new access controller instance. + * + * @return \Drupal\Core\Entity\EntityAccessControllerInterface. + * A access controller instance. + */ + public function getAccess(); + + /** * Sets a form class for a specific operation. * * @param string $operation 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/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationBlockListController.php b/core/modules/config_translation/lib/Drupal/config_translation/Controller/ConfigTranslationBlockListController.php index 35c10cc..1a67677 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,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Extension\ModuleHandlerInterface; /** * Defines the config translation controller for blocks. @@ -28,8 +27,8 @@ class ConfigTranslationBlockListController extends ConfigTranslationEntityListCo /** * {@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); $this->themes = list_themes(); } 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..e28eed7 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; @@ -67,7 +66,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.manager'), $definition ); @@ -80,15 +78,13 @@ 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, array $definition) { + parent::__construct($entity_info, $storage); $this->entityManager = $entity_manager; $this->baseEntityType = $definition['base_entity_type']; $this->baseEntityInfo = $this->entityManager->getDefinition($this->baseEntityType); 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..4920863 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 @@ -76,7 +76,8 @@ public function listing() { // 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); + $controller = new $class($this->entityManager()->getDefinition($entity_type), $this->entityManager()->getStorageController($entity_type), $this->entityManager(), $this->mapperDefinition); + $controller->setModuleHandler($this->moduleHandler()); $build = $controller->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_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 79b65b5..6c7d52c 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()));