diff --git a/core/core.services.yml b/core/core.services.yml index 1449b3b..5b5a474 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -193,7 +193,7 @@ services: arguments: ['@config.factory', '@module_handler', '@cache.cache', '@info_parser', '@router.builder'] entity.manager: class: Drupal\Core\Entity\EntityManager - arguments: ['@container.namespaces', '@service_container', '@module_handler', '@cache.cache', '@language_manager', '@string_translation'] + arguments: ['@container.namespaces', '@service_container', '@module_handler', '@cache.cache', '@language_manager'] plugin.manager.field.field_type: class: Drupal\Core\Field\FieldTypePluginManager arguments: ['@container.namespaces', '@cache.field', '@language_manager', '@module_handler'] diff --git a/core/includes/config.inc b/core/includes/config.inc index c7fca03..f6d5ce6 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -83,7 +83,7 @@ function ($value) use ($name) { } if ($entity_type = config_get_entity_type_by_name($name)) { $entity_manager - ->getStorageController($entity_type) + ->getDefinition($entity_type)->getStorage() ->create($new_config->get()) ->save(); } diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 28d2025..de1458a 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -52,9 +52,9 @@ function entity_info_cache_clear() { */ function entity_render_cache_clear() { $entity_manager = Drupal::entityManager(); - foreach ($entity_manager->getDefinitions() as $entity_type => $info) { - if ($entity_manager->hasController($entity_type, 'view_builder')) { - $entity_manager->getViewBuilder($entity_type)->resetCache(); + foreach ($entity_manager->getDefinitions() as $info) { + if ($info->hasController('view_builder')) { + $info->getViewBuilder()->resetCache(); } } } @@ -99,7 +99,7 @@ function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = N // Notify the entity storage controller. $method = 'onBundle' . ucfirst($hook); - $storage_controller = \Drupal::entityManager()->getStorageController($entity_type); + $storage_controller = \Drupal::entityManager()->getDefinition($entity_type)->getStorage(); if (method_exists($storage_controller, $method)) { $storage_controller->$method($bundle, $bundle_new); } @@ -202,7 +202,7 @@ function entity_get_view_modes($entity_type = NULL) { * @see \Drupal\Core\Entity\Query\QueryInterface */ function entity_load($entity_type, $id, $reset = FALSE) { - $controller = \Drupal::entityManager()->getStorageController($entity_type); + $controller = \Drupal::entityManager()->getDefinition($entity_type)->getStorage(); if ($reset) { $controller->resetCache(array($id)); } @@ -227,7 +227,7 @@ function entity_load($entity_type, $id, $reset = FALSE) { */ function entity_revision_load($entity_type, $revision_id) { return \Drupal::entityManager() - ->getStorageController($entity_type) + ->getDefinition($entity_type)->getStorage() ->loadRevision($revision_id); } @@ -241,7 +241,7 @@ function entity_revision_load($entity_type, $revision_id) { */ function entity_revision_delete($entity_type, $revision_id) { \Drupal::entityManager() - ->getStorageController($entity_type) + ->getDefinition($entity_type)->getStorage() ->deleteRevision($revision_id); } @@ -271,7 +271,7 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) { throw new EntityStorageException("Entity type $entity_type does not support UUIDs."); } - $controller = \Drupal::entityManager()->getStorageController($entity_type); + $controller = \Drupal::entityManager()->getDefinition($entity_type)->getStorage(); if ($reset) { $controller->resetCache(); } @@ -313,7 +313,7 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) { * @see \Drupal\Core\Entity\Query\QueryInterface */ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { - $controller = \Drupal::entityManager()->getStorageController($entity_type); + $controller = \Drupal::entityManager()->getDefinition($entity_type)->getStorage(); if ($reset) { $controller->resetCache($ids); } @@ -334,7 +334,7 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { */ function entity_load_multiple_by_properties($entity_type, array $values) { return \Drupal::entityManager() - ->getStorageController($entity_type) + ->getDefinition($entity_type)->getStorage() ->loadByProperties($values); } @@ -356,7 +356,7 @@ function entity_load_multiple_by_properties($entity_type, array $values) { */ function entity_load_unchanged($entity_type, $id) { return \Drupal::entityManager() - ->getStorageController($entity_type) + ->getDefinition($entity_type)->getStorage() ->loadUnchanged($id); } @@ -369,7 +369,7 @@ function entity_load_unchanged($entity_type, $id) { * An array of entity IDs of the entities to delete. */ function entity_delete_multiple($entity_type, array $ids) { - $controller = \Drupal::entityManager()->getStorageController($entity_type); + $controller = \Drupal::entityManager()->getDefinition($entity_type)->getStorage(); $entities = $controller->loadMultiple($ids); $controller->delete($entities); } @@ -388,7 +388,7 @@ function entity_delete_multiple($entity_type, array $ids) { */ function entity_create($entity_type, array $values) { return \Drupal::entityManager() - ->getStorageController($entity_type) + ->getDefinition($entity_type)->getStorage() ->create($values); } @@ -397,11 +397,11 @@ function entity_create($entity_type, array $values) { * * @return \Drupal\Core\Entity\EntityStorageControllerInterface * - * @deprecated Use \Drupal\Core\Entity\EntityManagerInterface::getStorageController(). + * @deprecated Use \Drupal\Core\Entity\EntityType::getStorage(). */ function entity_get_controller($entity_type) { return \Drupal::entityManager() - ->getStorageController($entity_type); + ->getDefinition($entity_type)->getStorage(); } /** @@ -427,50 +427,6 @@ function entity_page_label(EntityInterface $entity, $langcode = NULL) { } /** - * Returns the entity access controller for the given entity type. - * - * @param string $entity_type - * The type of the entity. - * - * @return \Drupal\Core\Entity\EntityAccessControllerInterface - * An entity access controller instance. - * - * @deprecated Use \Drupal\Core\Entity\EntityManagerInterface::getAccessController(). - */ -function entity_access_controller($entity_type) { - return \Drupal::entityManager() - ->getAccessController($entity_type); -} - -/** - * Returns an entity form controller for the given operation. - * - * Since there might be different scenarios in which an entity is edited, - * multiple form controllers suitable to the different operations may be defined. - * If no controller is found for the default operation, the base class will be - * used. If a non-existing non-default operation is specified an exception will - * be thrown. - * - * @see \Drupal\Core\Entity\EntityManagerInterface - * - * @param $entity_type - * The type of the entity. - * @param $operation - * (optional) The name of an operation, such as creation, editing or deletion, - * identifying the controlled form. Defaults to 'default' which is the usual - * create/edit form. - * - * @return \Drupal\Core\Entity\EntityFormControllerInterface - * An entity form controller instance. - * - * @deprecated Use \Drupal\Core\Entity\EntityManagerInterface::getFormController(). - */ -function entity_form_controller($entity_type, $operation = 'default') { - return \Drupal::entityManager() - ->getFormController($entity_type, $operation); -} - -/** * Returns the default form state for the given entity and operation. * * @param EntityInterface $entity @@ -483,7 +439,7 @@ function entity_form_controller($entity_type, $operation = 'default') { */ function entity_form_state_defaults(EntityInterface $entity, $operation = 'default') { $form_state = array(); - $controller = \Drupal::entityManager()->getFormController($entity->entityType(), $operation); + $controller = \Drupal::entityManager()->getDefinition($entity->entityType())->getForm($operation); $controller->setEntity($entity); $form_state['build_info']['callback_object'] = $controller; $form_state['build_info']['base_form_id'] = $controller->getBaseFormID(); @@ -536,22 +492,6 @@ function entity_get_form(EntityInterface $entity, $operation = 'default', array } /** - * Returns an entity list controller for a given entity type. - * - * @param string $entity_type - * The type of the entity. - * - * @return \Drupal\Core\Entity\EntityListControllerInterface - * An entity list controller. - * - * @deprecated Use \Drupal\Core\Entity\EntityManagerInterface::getFormController(). - */ -function entity_list_controller($entity_type) { - return \Drupal::entityManager() - ->getListController($entity_type); -} - -/** * Returns the render array for an entity. * * @param \Drupal\Core\Entity\EntityInterface $entity @@ -569,7 +509,7 @@ function entity_list_controller($entity_type) { * A render array for the entity. */ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) { - $render_controller = \Drupal::entityManager()->getViewBuilder($entity->entityType()); + $render_controller = \Drupal::entityManager()->getDefinition($entity->entityType())->getViewBuilder(); if ($reset) { $render_controller->resetCache(array($entity->id())); } @@ -595,7 +535,7 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res * entities array passed in $entities. */ function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) { - $render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->entityType()); + $render_controller = \Drupal::entityManager()->getDefinition(reset($entities)->entityType())->getViewBuilder(); if ($reset) { $render_controller->resetCache(array_keys($entities)); } @@ -840,19 +780,3 @@ function entity_get_render_form_display(EntityInterface $entity, $form_mode) { function entity_page_access(EntityInterface $entity, $operation = 'view') { return $entity->access($operation); } - -/** - * Generic access callback for create entity pages. - * - * @param string $entity_type - * The entity type. - * @param string $bundle - * (optional) The bundle of the entity. Required if the entity supports - * bundles, defaults to NULL otherwise. - * - * @return bool - * TRUE if the access is granted. FALSE if access is denied. - */ -function entity_page_create_access($entity_type, $bundle = NULL) { - return \Drupal::entityManager()->getAccessController($entity_type)->createAccess($bundle); -} diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 856c424..64e5d96 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -2506,7 +2506,7 @@ function menu_cache_clear_all() { */ function menu_reset_static_cache() { \Drupal::entityManager() - ->getStorageController('menu_link')->resetCache(); + ->getDefinition('menu_link')->getStorage()->resetCache(); drupal_static_reset('_menu_build_tree'); drupal_static_reset('menu_tree'); drupal_static_reset('menu_tree_all_data'); @@ -2659,7 +2659,7 @@ function _menu_navigation_links_rebuild($menu) { return; } $menu_link_controller = \Drupal::entityManager() - ->getStorageController('menu_link'); + ->getDefinition('menu_link')->getStorage(); // Add normal and suggested items as links. $router_items = array(); diff --git a/core/lib/Drupal/Core/Config/ConfigImporter.php b/core/lib/Drupal/Core/Config/ConfigImporter.php index dd5b9bb..35a6479 100644 --- a/core/lib/Drupal/Core/Config/ConfigImporter.php +++ b/core/lib/Drupal/Core/Config/ConfigImporter.php @@ -321,7 +321,7 @@ protected function importInvokeOwner() { } $method = 'import' . ucfirst($op); - $handled_by_module = $this->entityManager->getStorageController($entity_type)->$method($name, $new_config, $old_config); + $handled_by_module = $this->entityManager->getDefinition($entity_type)->getStorage()->$method($name, $new_config, $old_config); } if (!empty($handled_by_module)) { $this->setProcessed($op, $name); diff --git a/core/lib/Drupal/Core/Config/Entity/DraggableListController.php b/core/lib/Drupal/Core/Config/Entity/DraggableListController.php index 8e61eb4..c620762 100644 --- a/core/lib/Drupal/Core/Config/Entity/DraggableListController.php +++ b/core/lib/Drupal/Core/Config/Entity/DraggableListController.php @@ -8,9 +8,7 @@ namespace Drupal\Core\Config\Entity; 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; /** @@ -42,8 +40,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) { + parent::__construct($entity_info); // Check if the entity type supports weighting. if ($this->entityInfo->hasKey('weight')) { diff --git a/core/lib/Drupal/Core/Datetime/Date.php b/core/lib/Drupal/Core/Datetime/Date.php index 0510fa4..a0f9b9a 100644 --- a/core/lib/Drupal/Core/Datetime/Date.php +++ b/core/lib/Drupal/Core/Datetime/Date.php @@ -73,7 +73,7 @@ class Date { * The string translation. */ public function __construct(EntityManagerInterface $entity_manager, LanguageManager $language_manager, TranslationInterface $translation) { - $this->dateFormatStorage = $entity_manager->getStorageController('date_format'); + $this->dateFormatStorage = $entity_manager->getDefinition('date_format')->getStorage(); $this->languageManager = $language_manager; $this->stringTranslation = $translation; } diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 9d502d2..7cd9812 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -538,12 +538,10 @@ public function isEmpty() { */ public function access($operation = 'view', AccountInterface $account = NULL) { if ($operation == 'create') { - return \Drupal::entityManager() - ->getAccessController($this->entityType) + return $this->entityInfo()->getAccess() ->createAccess($this->bundle(), $account); } - return \Drupal::entityManager() - ->getAccessController($this->entityType) + return $this->entityInfo()->getAccess() ->access($this, $operation, $this->activeLangcode, $account); } @@ -725,9 +723,7 @@ public function addTranslation($langcode, array $values = array()) { // specified language. $info = $this->entityInfo(); $default_values = array($info->getKey('bundle') => $this->bundle, 'langcode' => $langcode); - $entity = \Drupal::entityManager() - ->getStorageController($this->entityType()) - ->create($default_values); + $entity = $this->entityInfo()->getStorage()->create($default_values); foreach ($entity as $name => $field) { if (!isset($values[$name]) && !$field->isEmpty()) { diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityListController.php b/core/lib/Drupal/Core/Entity/Controller/EntityListController.php index 7a07a38..a90025c 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityListController.php @@ -25,7 +25,7 @@ class EntityListController extends ControllerBase { * A render array as expected by drupal_render(). */ public function listing($entity_type) { - return $this->entityManager()->getListController($entity_type)->render(); + return $this->entityManager()->getDefinition($entity_type)->getList()->render(); } } diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php index d11e4a6..35886bb 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php @@ -62,7 +62,8 @@ public static function create(ContainerInterface $container) { */ public function view(EntityInterface $_entity, $view_mode = 'full', $langcode = NULL) { return $this->entityManager - ->getViewBuilder($_entity->entityType()) + ->getDefinition($_entity->entityType()) + ->getViewBuilder() ->view($_entity, $view_mode, $langcode); } diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 2e4a7ea..2db6758 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -254,12 +254,10 @@ public function uriRelationships() { */ public function access($operation = 'view', AccountInterface $account = NULL) { if ($operation == 'create') { - return \Drupal::entityManager() - ->getAccessController($this->entityType) + return $this->entityInfo()->getAccess() ->createAccess($this->bundle(), $account); } - return \Drupal::entityManager() - ->getAccessController($this->entityType) + return $this->entityInfo()->getAccess() ->access($this, $operation, Language::LANGCODE_DEFAULT, $account); } @@ -279,7 +277,7 @@ public function language() { * {@inheritdoc} */ public function save() { - return \Drupal::entityManager()->getStorageController($this->entityType)->save($this); + return $this->entityInfo()->getStorage()->save($this); } /** @@ -287,7 +285,7 @@ public function save() { */ public function delete() { if (!$this->isNew()) { - \Drupal::entityManager()->getStorageController($this->entityType)->delete(array($this->id() => $this)); + $this->entityInfo()->getStorage()->delete(array($this->id() => $this)); } } @@ -379,9 +377,10 @@ public function changed() { $referenced_entities[$referenced_entity->entityType()][$referenced_entity->id()] = $referenced_entity; } - foreach ($referenced_entities as $entity_type => $entities) { - if (\Drupal::entityManager()->hasController($entity_type, 'view_builder')) { - \Drupal::entityManager()->getViewBuilder($entity_type)->resetCache($entities); + foreach ($referenced_entities as $entity_type_name => $entities) { + $entity_type = \Drupal::entityManager()->getDefinition($entity_type_name); + if ($entity_type->hasController('view_builder')) { + $entity_type->getViewBuilder()->resetCache($entities); } } } diff --git a/core/lib/Drupal/Core/Entity/EntityCreateAccessCheck.php b/core/lib/Drupal/Core/Entity/EntityCreateAccessCheck.php index 1cf7d87..b866dd3 100644 --- a/core/lib/Drupal/Core/Entity/EntityCreateAccessCheck.php +++ b/core/lib/Drupal/Core/Entity/EntityCreateAccessCheck.php @@ -59,7 +59,7 @@ public function access(Route $route, Request $request, AccountInterface $account return static::DENY; } } - return $this->entityManager->getAccessController($entity_type)->createAccess($bundle, $account) ? static::ALLOW : static::DENY; + return $this->entityManager->getDefinition($entity_type)->getAccess()->createAccess($bundle, $account) ? static::ALLOW : static::DENY; } } diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 2ea0fbe..687bcbf 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -442,4 +442,14 @@ public function setModuleHandler(ModuleHandlerInterface $module_handler) { return $this; } + /** + * Returns the storage for this form's entity. + * + * @return \Drupal\Core\Entity\EntityStorageControllerInterface + * The storage for this form's entity. + */ + protected function getStorage() { + return $this->entity->entityInfo()->getStorage(); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index fdbc6a9..8c084e0 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -58,9 +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') + $entity_info ); } @@ -69,23 +67,11 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * 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) { $this->entityType = $entity_info->id(); - $this->storage = $storage; + $this->storage = $entity_info->getStorage(); $this->entityInfo = $entity_info; - $this->moduleHandler = $module_handler; - } - - /** - * Implements \Drupal\Core\Entity\EntityListControllerInterface::getStorageController(). - */ - public function getStorageController() { - return $this->storage; } /** @@ -247,6 +233,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..70659f3 100644 --- a/core/lib/Drupal/Core/Entity/EntityListControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityListControllerInterface.php @@ -7,20 +7,15 @@ namespace Drupal\Core\Entity; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\StringTranslation\TranslationInterface; + /** * Defines an interface for entity list controllers. */ interface EntityListControllerInterface { /** - * Gets the entity storage controller. - * - * @return \Drupal\Core\Entity\EntityStorageControllerInterface - * The storage controller used by this list controller. - */ - public function getStorageController(); - - /** * Loads entities of this type from storage for listing. * * This allows the controller to manipulate the list, like filtering or @@ -55,4 +50,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 bffc91b..db97325 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -100,13 +100,6 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface protected $namespaces; /** - * The string translationManager. - * - * @var \Drupal\Core\StringTranslation\TranslationInterface - */ - protected $translationManager; - - /** * Static cache of bundle information. * * @var array @@ -127,17 +120,14 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface * The cache backend to use. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. - * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager - * The string translationManager. */ - public function __construct(\Traversable $namespaces, ContainerInterface $container, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, LanguageManager $language_manager, TranslationInterface $translation_manager) { + public function __construct(\Traversable $namespaces, ContainerInterface $container, ModuleHandlerInterface $module_handler, CacheBackendInterface $cache, LanguageManager $language_manager) { // Allow the plugin definition to be altered by hook_entity_info_alter(). $this->moduleHandler = $module_handler; $this->cache = $cache; $this->languageManager = $language_manager; $this->namespaces = $namespaces; - $this->translationManager = $translation_manager; $this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, 'Drupal\Core\Entity\Annotation\EntityType'); $this->discovery = new InfoHookDecorator($this->discovery, 'entity_info'); @@ -159,134 +149,6 @@ public function clearCachedDefinitions() { /** * {@inheritdoc} */ - public function hasController($entity_type, $controller_type) { - if ($definition = $this->getDefinition($entity_type)) { - return $definition->hasController($controller_type); - } - return FALSE; - } - - /** - * {@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'); - } - - /** - * {@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]; - } - - /** - * {@inheritdoc} - */ - public function getFormController($entity_type, $operation) { - if (!isset($this->controllers['form'][$operation][$entity_type])) { - $class = $this->getControllerClass($entity_type, 'form', $operation); - if (in_array('Drupal\Core\DependencyInjection\ContainerInjectionInterface', class_implements($class))) { - $controller = $class::create($this->container); - } - else { - $controller = new $class(); - } - - $controller - ->setTranslationManager($this->translationManager) - ->setModuleHandler($this->moduleHandler) - ->setOperation($operation); - $this->controllers['form'][$operation][$entity_type] = $controller; - } - return $this->controllers['form'][$operation][$entity_type]; - } - - /** - * {@inheritdoc} - */ - public function getViewBuilder($entity_type) { - return $this->getController($entity_type, 'view_builder'); - } - - /** - * {@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]; - } - - /** - * 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. - */ - 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)); - } - } - return $this->controllers[$controller_type][$entity_type]; - } - - /** - * {@inheritdoc} - */ public function getForm(EntityInterface $entity, $operation = 'default', array $form_state = array()) { $form_state += entity_form_state_defaults($entity, $operation); $form_id = $form_state['build_info']['callback_object']->getFormId(); @@ -491,4 +353,22 @@ public function getTranslationFromContext(EntityInterface $entity, $langcode = N return $translation; } + /** + * {@inheritdoc} + * + * @return \Drupal\Core\Entity\EntityTypeInterface[] + */ + public function getDefinitions() { + return parent::getDefinitions(); + } + + /** + * {@inheritdoc} + * + * @return \Drupal\Core\Entity\EntityTypeInterface|null + */ + public function getDefinition($plugin_id) { + return parent::getDefinition($plugin_id); + } + } diff --git a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php index cb962e0..486aff5 100644 --- a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php @@ -43,17 +43,6 @@ public function getEntityTypeLabels(); public function getFieldDefinitions($entity_type, $bundle = NULL); /** - * Creates a new access controller instance. - * - * @param string $entity_type - * The entity type for this access controller. - * - * @return \Drupal\Core\Entity\EntityAccessControllerInterface. - * A access controller instance. - */ - public function getAccessController($entity_type); - - /** * Returns the route information for an entity type's bundle. * * @param string $entity_type @@ -94,33 +83,6 @@ public function getAdminRouteInfo($entity_type, $bundle); public function getFieldDefinitionsByConstraints($entity_type, array $constraints); /** - * Creates a new storage controller instance. - * - * @param string $entity_type - * The entity type for this storage controller. - * - * @return \Drupal\Core\Entity\EntityStorageControllerInterface - * A storage controller instance. - */ - 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 @@ -134,17 +96,6 @@ public function getAllBundleInfo(); public function clearCachedDefinitions(); /** - * Creates a new view builder instance. - * - * @param string $entity_type - * The entity type for this view builder. - * - * @return \Drupal\Core\Entity\EntityViewBuilderInterface. - * A render controller instance. - */ - public function getViewBuilder($entity_type); - - /** * Returns the administration path for an entity type's bundle. * * @param string $entity_type @@ -163,48 +114,11 @@ public function getViewBuilder($entity_type); public function getAdminPath($entity_type, $bundle); /** - * Creates a new list controller instance. - * - * @param string $entity_type - * The entity type for this list controller. - * - * @return \Drupal\Core\Entity\EntityListControllerInterface - * A list controller instance. - */ - public function getListController($entity_type); - - /** - * Creates a new form controller instance. - * - * @param string $entity_type - * The entity type for this form controller. - * @param string $operation - * The name of the operation to use, e.g., 'default'. - * - * @return \Drupal\Core\Entity\EntityFormControllerInterface - * A form controller instance. - */ - public function getFormController($entity_type, $operation); - - /** * Clears static and persistent field definition caches. */ public function clearCachedFieldDefinitions(); /** - * Checks whether a certain entity type has a certain controller. - * - * @param string $entity_type - * The name of the entity type. - * @param string $controller_type - * The name of the controller. - * - * @return bool - * Returns TRUE if the entity type has the controller, else FALSE. - */ - public function hasController($entity_type, $controller_type); - - /** * Returns the built and processed entity form for the given entity. * * @param \Drupal\Core\Entity\EntityInterface $entity diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index 1d86e02..113de26 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -341,6 +341,74 @@ public function hasController($controller_type) { /** * {@inheritdoc} */ + public function getStorage() { + $class = $this->getController('storage'); + return $this->getControllerInstance($class); + } + + /** + * {@inheritdoc} + */ + public function getForm($operation) { + $forms = $this->getController('form'); + $class = $forms[$operation]; + if (in_array('Drupal\Core\DependencyInjection\ContainerInjectionInterface', class_implements($class))) { + $controller = $class::create(\Drupal::getContainer()); + } + else { + $controller = new $class(); + } + + $controller + ->setTranslationManager(\Drupal::translation()) + ->setModuleHandler(\Drupal::moduleHandler()) + ->setOperation($operation); + return $controller; + } + + /** + * {@inheritdoc} + */ + public function getList() { + $class = $this->getController('list'); + $controller = $this->getControllerInstance($class); + $controller->setModuleHandler(\Drupal::moduleHandler()); + return $controller; + } + + /** + * {@inheritdoc} + */ + public function getViewBuilder() { + $class = $this->getController('view_builder'); + return $this->getControllerInstance($class); + } + + /** + * {@inheritdoc} + */ + public function getAccess() { + $class = $this->getController('access'); + $controller = $this->getControllerInstance($class); + $controller->setModuleHandler(\Drupal::moduleHandler()); + return $controller; + } + + /** + * {@inheritdoc} + */ + public function getControllerInstance($class) { + if (in_array('Drupal\Core\Entity\EntityControllerInterface', class_implements($class))) { + return $class::createInstance(\Drupal::getContainer(), $this); + } + else { + return new $class($this); + } + } + + /** + * {@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..438e8f1 100644 --- a/core/lib/Drupal/Core/Entity/EntityTypeInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php @@ -202,6 +202,59 @@ 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(); + + /** + * Creates a new controller instance. + * + * @param string $class + * The class to create an instance for. + * + * @return mixed + * A controller instance. + */ + public function getControllerInstance($class); + + /** * Sets a form class for a specific operation. * * @param string $operation diff --git a/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php b/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php index 44a0bf3..3e36f69 100644 --- a/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php +++ b/core/lib/Drupal/Core/Entity/HtmlEntityFormController.php @@ -67,14 +67,15 @@ protected function getFormObject(Request $request, $form_arg) { $form_arg .= '.default'; list ($entity_type, $operation) = explode('.', $form_arg); + $definition = $this->manager->getDefinition($entity_type); if ($request->attributes->has($entity_type)) { $entity = $request->attributes->get($entity_type); } else { - $entity = $this->manager->getStorageController($entity_type)->create(array()); + $entity = $definition->getStorage()->create(array()); } - return $this->manager->getFormController($entity_type, $operation)->setEntity($entity); + return $definition->getForm($operation)->setEntity($entity); } } diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php index 5101d80..025ef10 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php @@ -21,9 +21,10 @@ class EntityChangedConstraintValidator extends ConstraintValidator { */ public function validate($value, Constraint $constraint) { if (isset($value)) { + /** @var $entity \Drupal\Core\Entity\EntityInterface */ $entity = $this->context->getMetadata()->getTypedData()->getEntity(); if (!$entity->isNew()) { - $saved_entity = \Drupal::entityManager()->getStorageController($entity->entityType())->loadUnchanged($entity->id()); + $saved_entity = $entity->entityInfo()->getStorage()->loadUnchanged($entity->id()); if ($saved_entity && ($saved_entity instanceof EntityChangedInterface) && ($saved_entity->getChangedTime() > $value)) { $this->context->addViolation($constraint->message); diff --git a/core/lib/Drupal/Core/Entity/Query/QueryFactory.php b/core/lib/Drupal/Core/Entity/Query/QueryFactory.php index 27bccbd..96b742e 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryFactory.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryFactory.php @@ -45,7 +45,7 @@ public function __construct(EntityManagerInterface $entity_manager) { * The query object that can query the given entity type. */ public function get($entity_type, $conjunction = 'AND') { - $service_name = $this->entityManager->getStorageController($entity_type)->getQueryServicename(); + $service_name = $this->entityManager->getDefinition($entity_type)->getStorage()->getQueryServicename(); return $this->container->get($service_name)->get($entity_type, $conjunction, $this->entityManager); } @@ -62,7 +62,7 @@ public function get($entity_type, $conjunction = 'AND') { * The aggregated query object that can query the given entity type. */ public function getAggregate($entity_type, $conjunction = 'AND') { - $service_name = $this->entityManager->getStorageController($entity_type)->getQueryServicename(); + $service_name = $this->entityManager->getDefinition($entity_type)->getStorage()->getQueryServicename(); return $this->container->get($service_name)->getAggregate($entity_type, $conjunction, $this->entityManager); } diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php index 8ec71e1..3c65c0b 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Tables.php @@ -142,7 +142,8 @@ public function addField($field, $type, $langcode) { $values[$bundle_key] = reset($field_map[$entity_type][$field_name]['bundles']); } $entity = $entity_manager - ->getStorageController($entity_type) + ->getDefinition($entity_type) + ->getStorage() ->create($values); $propertyDefinitions = $entity->$field_name->getPropertyDefinitions(); @@ -196,7 +197,8 @@ public function addField($field, $type, $langcode) { $values[$bundle_key] = key($bundles); } $entity = $entity_manager - ->getStorageController($entity_type) + ->getDefinition($entity_type) + ->getStorage() ->create($values); $propertyDefinitions = $entity->$specifier->getPropertyDefinitions(); $relationship_specifier = $specifiers[$key + 1]; diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index 1af3254..6ba612f 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -193,7 +193,7 @@ public function __unset($property_name) { * {@inheritdoc} */ public function access($operation = 'view', AccountInterface $account = NULL) { - $access_controller = \Drupal::entityManager()->getAccessController($this->getParent()->entityType()); + $access_controller = \Drupal::entityManager()->getDefinition($this->getParent()->entityType())->getAccess(); return $access_controller->fieldAccess($operation, $this->getFieldDefinition(), $account, $this); } diff --git a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php index cc0ffed..0e0b142 100644 --- a/core/lib/Drupal/Core/ParamConverter/EntityConverter.php +++ b/core/lib/Drupal/Core/ParamConverter/EntityConverter.php @@ -38,7 +38,7 @@ public function __construct(EntityManagerInterface $entity_manager) { */ public function convert($value, $definition, $name, array $defaults, Request $request) { $entity_type = substr($definition['type'], strlen('entity:')); - if ($storage = $this->entityManager->getStorageController($entity_type)) { + if ($storage = $this->entityManager->getDefinition($entity_type)->getStorage()) { return $storage->load($value); } } diff --git a/core/lib/Drupal/Core/Session/UserSession.php b/core/lib/Drupal/Core/Session/UserSession.php index af33674..671cb96 100644 --- a/core/lib/Drupal/Core/Session/UserSession.php +++ b/core/lib/Drupal/Core/Session/UserSession.php @@ -128,7 +128,7 @@ public function hasPermission($permission) { return TRUE; } - $roles = \Drupal::entityManager()->getStorageController('user_role')->loadMultiple($this->getRoles()); + $roles = \Drupal::entityManager()->getDefinition('user_role')->getStorage()->loadMultiple($this->getRoles()); foreach ($roles as $role) { if ($role->hasPermission($permission)) { diff --git a/core/modules/action/lib/Drupal/action/ActionAddFormController.php b/core/modules/action/lib/Drupal/action/ActionAddFormController.php index a1cf893..b7eb6bf 100644 --- a/core/modules/action/lib/Drupal/action/ActionAddFormController.php +++ b/core/modules/action/lib/Drupal/action/ActionAddFormController.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\Crypt; use Drupal\Core\Action\ActionManager; -use Drupal\Core\Entity\EntityStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -27,14 +26,10 @@ class ActionAddFormController extends ActionFormControllerBase { /** * Constructs a new ActionAddFormController. * - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller - * The action storage controller. * @param \Drupal\Core\Action\ActionManager $action_manager * The action plugin manager. */ - public function __construct(EntityStorageControllerInterface $storage_controller, ActionManager $action_manager) { - parent::__construct($storage_controller); - + public function __construct(ActionManager $action_manager) { $this->actionManager = $action_manager; } @@ -43,7 +38,6 @@ public function __construct(EntityStorageControllerInterface $storage_controller */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('action'), $container->get('plugin.manager.action') ); } diff --git a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php index 3cf0cde..c05aa59 100644 --- a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php +++ b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php @@ -8,9 +8,7 @@ namespace Drupal\action; use Drupal\Core\Entity\EntityFormController; -use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Plugin\PluginFormInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides a base form controller for action forms. @@ -25,32 +23,6 @@ protected $plugin; /** - * The action storage controller. - * - * @var \Drupal\Core\Entity\EntityStorageControllerInterface - */ - protected $storageController; - - /** - * Constructs a new action form. - * - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller - * The action storage controller. - */ - public function __construct(EntityStorageControllerInterface $storage_controller) { - $this->storageController = $storage_controller; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.manager')->getStorageController('action') - ); - } - - /** * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { @@ -106,7 +78,7 @@ public function form(array $form, array &$form_state) { * TRUE if the action exists, FALSE otherwise. */ public function exists($id) { - $action = $this->storageController->load($id); + $action = $this->getStorage()->load($id); return !empty($action); } diff --git a/core/modules/action/lib/Drupal/action/ActionListController.php b/core/modules/action/lib/Drupal/action/ActionListController.php index 03f7b75..fe20e56 100644 --- a/core/modules/action/lib/Drupal/action/ActionListController.php +++ b/core/modules/action/lib/Drupal/action/ActionListController.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityInterface; 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; @@ -38,15 +37,11 @@ class ActionListController extends ConfigEntityListController implements EntityC * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * The entity info for the entity type. - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage - * 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, ActionManager $action_manager) { + parent::__construct($entity_info); $this->actionManager = $action_manager; } @@ -57,9 +52,7 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) { 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/action/lib/Drupal/action/Plugin/Action/EmailAction.php b/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php index a924861..93ae52c 100644 --- a/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php +++ b/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php @@ -56,7 +56,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi parent::__construct($configuration, $plugin_id, $plugin_definition); $this->token = $token; - $this->storageController = $entity_manager->getStorageController('user'); + $this->storageController = $entity_manager->getDefinition('user')->getStorage(); } /** diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index 75e4997..11ff47e 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -31,7 +31,7 @@ * An array of the feed items. */ function aggregator_load_feed_items($type, $data = NULL, $limit = 20) { - $storage_controller = \Drupal::entityManager()->getStorageController('aggregator_item'); + $storage_controller = \Drupal::entityManager()->getDefinition('aggregator_item')->getStorage(); switch ($type) { case 'sum': return $storage_controller->loadAll($limit); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php index f9b25b9..9a53a1f 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Controller/AggregatorController.php @@ -57,7 +57,7 @@ public static function create(ContainerInterface $container) { */ public function feedAdd() { $entity_manager = $this->entityManager(); - $feed = $entity_manager->getStorageController('aggregator_feed') + $feed = $entity_manager->getDefinition('aggregator_feed')->getStorage() ->create(array( 'refresh' => 3600, )); @@ -75,10 +75,10 @@ public function feedAdd() { */ public function viewFeed(FeedInterface $aggregator_feed) { $entity_manager = $this->entityManager(); - $feed_source = $entity_manager->getViewBuilder('aggregator_feed') + $feed_source = $entity_manager->getDefinition('aggregator_feed')->getViewBuilder() ->view($aggregator_feed, 'default'); // Load aggregator feed item for the particular feed id. - $items = $entity_manager->getStorageController('aggregator_item')->loadByFeed($aggregator_feed->id()); + $items = $entity_manager->getDefinition('aggregator_item')->getStorage()->loadByFeed($aggregator_feed->id()); // Print the feed items. $build = $this->buildPageList($items, $feed_source); return $build; @@ -103,7 +103,7 @@ protected function buildPageList(array $items, $feed_source = '') { ); $build['feed_source'] = is_array($feed_source) ? $feed_source : array('#markup' => $feed_source); if ($items) { - $build['items'] = $this->entityManager()->getViewBuilder('aggregator_item') + $build['items'] = $this->entityManager()->getDefinition('aggregator_item')->getViewBuilder() ->viewMultiple($items, 'default'); $build['pager'] = array('#theme' => 'pager'); } @@ -192,7 +192,7 @@ public function adminOverview() { * The rendered list of items for the feed. */ public function pageLast() { - $items = $this->entityManager()->getStorageController('aggregator_item')->loadAll(); + $items = $this->entityManager()->getDefinition('aggregator_item')->getStorage()->loadAll(); $build = $this->buildPageList($items); $build['#attached']['drupal_add_feed'][] = array('aggregator/rss', $this->config('system.site')->get('name') . ' ' . $this->t('aggregator')); return $build; @@ -207,7 +207,7 @@ public function pageLast() { public function sources() { $entity_manager = $this->entityManager(); - $feeds = $entity_manager->getStorageController('aggregator_feed')->loadMultiple(); + $feeds = $entity_manager->getDefinition('aggregator_feed')->getStorage()->loadMultiple(); $build = array( '#type' => 'container', @@ -215,17 +215,16 @@ public function sources() { '#sorted' => TRUE, ); + $item_entity_type = $entity_manager->getDefinition('aggregator_item'); foreach ($feeds as $feed) { // Most recent items: $summary_items = array(); $aggregator_summary_items = $this->config('aggregator.settings') ->get('source.list_max'); if ($aggregator_summary_items) { - $items = $entity_manager->getStorageController('aggregator_item') - ->loadByFeed($feed->id()); + $items = $item_entity_type->getStorage()->loadByFeed($feed->id()); if ($items) { - $summary_items = $entity_manager->getViewBuilder('aggregator_item') - ->viewMultiple($items, 'summary'); + $summary_items = $item_entity_type->getViewBuilder()->viewMultiple($items, 'summary'); } } $feed->url = $this->url('aggregator.feed_view', array('aggregator_feed' => $feed->id())); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php index f651742..9a5ccda 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php @@ -218,7 +218,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont ->condition('settings.feed', array_keys($entities)) ->execute(); if ($ids) { - $block_storage = \Drupal::entityManager()->getStorageController('block'); + $block_storage = \Drupal::entityManager()->getDefinition('block')->getStorage(); $block_storage->delete($block_storage->loadMultiple($ids)); } } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php index fd95205..5a5219f 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php @@ -66,8 +66,7 @@ public function form(array $form, array &$form_state) { public function validate(array $form, array &$form_state) { $feed = $this->buildEntity($form, $form_state); // Check for duplicate titles. - $feed_storage_controller = $this->entityManager->getStorageController('aggregator_feed'); - $result = $feed_storage_controller->getFeedDuplicates($feed); + $result = $this->getStorage()->getFeedDuplicates($feed); foreach ($result as $item) { if (strcasecmp($item->title, $feed->label()) == 0) { $this->setFormError('title', $form_state, $this->t('A feed named %feed already exists. Enter a unique title.', array('%feed' => $feed->label()))); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php index 8aec75b..532d10c 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php @@ -64,7 +64,7 @@ public function __construct(QueryFactory $query_factory, FeedStorageControllerIn public static function create(ContainerInterface $container) { return new static( $container->get('entity.query'), - $container->get('entity.manager')->getStorageController('aggregator_feed'), + $container->get('entity.manager')->getDefinition('aggregator_feed')->getStorage(), $container->get('http_default_client') ); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php index 767639e..143a4e0 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/Block/AggregatorFeedBlock.php @@ -68,7 +68,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('entity.manager')->getStorageController('aggregator_feed'), + $container->get('entity.manager')->getDefinition('aggregator_feed')->getStorage(), $container->get('database') ); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/argument/Fid.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/argument/Fid.php index b6601c2..8d035ac 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/argument/Fid.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/argument/Fid.php @@ -58,7 +58,7 @@ public static function create(ContainerInterface $container, array $configuratio function titleQuery() { $titles = array(); - $feeds = $this->entityManager->getStorageController('aggregator_feed')->loadMultiple($this->value); + $feeds = $this->entityManager->getDefinition('aggregator_feed')->getStorage()->loadMultiple($this->value); foreach ($feeds as $feed) { $titles[] = String::checkPlain($feed->label()); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/argument/Iid.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/argument/Iid.php index 2fef3be..725d38d 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/argument/Iid.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/argument/Iid.php @@ -58,7 +58,7 @@ public static function create(ContainerInterface $container, array $configuratio function titleQuery() { $titles = array(); - $items = $this->entityManager->getStorageController('aggregator_item')->loadMultiple($this->value); + $items = $this->entityManager->getDefinition('aggregator_item')->getStorage()->loadMultiple($this->value); foreach ($items as $feed) { $titles[] = String::checkPlain($feed->label()); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/RemoveFeedTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/RemoveFeedTest.php index d827be8..e76e8c4 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/RemoveFeedTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/RemoveFeedTest.php @@ -45,7 +45,7 @@ function testRemoveFeed() { // Delete feed. $this->deleteFeed($feed1); $this->assertText($feed2->label()); - $block_storage = $this->container->get('entity.manager')->getStorageController('block'); + $block_storage = \Drupal::entityManager()->getDefinition('block')->getStorage(); $this->assertNull($block_storage->load($block->id()), 'Block for the deleted feed was deleted.'); $this->assertEqual($block2->id(), $block_storage->load($block2->id())->id(), 'Block for not deleted feed still exists.'); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/Views/IntegrationTest.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/Views/IntegrationTest.php index 6fd1f93..b1ffef8 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/Views/IntegrationTest.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/Views/IntegrationTest.php @@ -58,8 +58,8 @@ protected function setUp() { ViewTestData::createTestViews(get_class($this), array('aggregator_test_views')); - $this->itemStorageController = $this->container->get('entity.manager')->getStorageController('aggregator_item'); - $this->feedStorageController = $this->container->get('entity.manager')->getStorageController('aggregator_feed'); + $this->itemStorageController = \Drupal::entityManager()->getDefinition('aggregator_item')->getStorage(); + $this->feedStorageController = \Drupal::entityManager()->getDefinition('aggregator_feed')->getStorage(); } /** diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php index 6469baf..197f766 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Controller/CustomBlockController.php @@ -45,8 +45,8 @@ public static function create(ContainerInterface $container) { $entity_manager = $container->get('entity.manager'); return new static( $entity_manager, - $entity_manager->getStorageController('custom_block'), - $entity_manager->getStorageController('custom_block_type') + $entity_manager->getDefinition('custom_block')->getStorage(), + $entity_manager->getDefinition('custom_block_type')->getStorage() ); } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php index 3befde0..6a41170 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php @@ -10,7 +10,6 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\ContentEntityFormController; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -21,13 +20,6 @@ class CustomBlockFormController extends ContentEntityFormController { /** - * The custom block storage. - * - * @var \Drupal\Core\Entity\EntityStorageControllerInterface - */ - protected $customBlockStorage; - - /** * The language manager. * * @var \Drupal\Core\Language\LanguageManager @@ -39,14 +31,11 @@ class CustomBlockFormController extends ContentEntityFormController { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $custom_block_storage - * The custom block storage controller. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. */ - public function __construct(EntityManagerInterface $entity_manager, EntityStorageControllerInterface $custom_block_storage, LanguageManager $language_manager) { + public function __construct(EntityManagerInterface $entity_manager, LanguageManager $language_manager) { parent::__construct($entity_manager); - $this->customBlockStorage = $custom_block_storage; $this->languageManager = $language_manager; } @@ -54,10 +43,8 @@ public function __construct(EntityManagerInterface $entity_manager, EntityStorag * {@inheritdoc} */ public static function create(ContainerInterface $container) { - $entity_manager = $container->get('entity.manager'); return new static( - $entity_manager, - $entity_manager->getStorageController('custom_block'), + $container->get('entity.manager'), $container->get('language_manager') ); } @@ -274,7 +261,7 @@ public function delete(array $form, array &$form_state) { */ public function validateForm(array &$form, array &$form_state) { if ($this->entity->isNew()) { - $exists = $this->customBlockStorage->loadByProperties(array('info' => $form_state['values']['info'])); + $exists = $this->getStorage()->loadByProperties(array('info' => $form_state['values']['info'])); if (!empty($exists)) { $this->setFormError('info', $form_state, $this->t('A block with description %name already exists.', array( '%name' => $form_state['values']['info'], diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockListTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockListTest.php index 3678a23..4cb52d1 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockListTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockListTest.php @@ -82,7 +82,7 @@ public function testListing() { // Edit the entity using the operations link. $blocks = $this->container ->get('entity.manager') - ->getStorageController('custom_block') + ->getDefinition('custom_block')->getStorage() ->loadByProperties(array('info' => $label)); $block = reset($blocks); if (!empty($block)) { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php index 7593adb..0170bad 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockTypeTest.php @@ -149,7 +149,7 @@ public function testsCustomBlockAddTypes() { // Get the custom block storage controller. $storage_controller = $this->container ->get('entity.manager') - ->getStorageController('custom_block'); + ->getDefinition('custom_block')->getStorage(); // Enable all themes. theme_enable(array('bartik', 'seven')); diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 92bbe88..b844dd7 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -10,7 +10,6 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Config\ConfigFactory; use Drupal\Core\Entity\EntityFormController; -use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Language\Language; use Drupal\Core\Language\LanguageManager; @@ -29,13 +28,6 @@ class BlockFormController extends EntityFormController { protected $entity; /** - * The block storage controller. - * - * @var \Drupal\Core\Entity\EntityStorageControllerInterface - */ - protected $storageController; - - /** * The entity query factory. * * @var \Drupal\Core\Entity\Query\QueryFactory @@ -59,8 +51,6 @@ class BlockFormController extends EntityFormController { /** * Constructs a BlockFormController object. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory * The entity query factory. * @param \Drupal\Core\Language\LanguageManager $language_manager @@ -68,8 +58,7 @@ class BlockFormController extends EntityFormController { * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory. */ - public function __construct(EntityManagerInterface $entity_manager, QueryFactory $entity_query_factory, LanguageManager $language_manager, ConfigFactory $config_factory) { - $this->storageController = $entity_manager->getStorageController('block'); + public function __construct(QueryFactory $entity_query_factory, LanguageManager $language_manager, ConfigFactory $config_factory) { $this->entityQueryFactory = $entity_query_factory; $this->languageManager = $language_manager; $this->configFactory = $config_factory; @@ -80,7 +69,6 @@ public function __construct(EntityManagerInterface $entity_manager, QueryFactory */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager'), $container->get('entity.query'), $container->get('language_manager'), $container->get('config.factory') diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 8547ba4..b6c24a9 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -13,9 +13,7 @@ use Drupal\Core\Config\Entity\ConfigEntityListController; use Drupal\Core\Entity\EntityControllerInterface; 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; use Symfony\Component\HttpFoundation\Request; @@ -58,15 +56,11 @@ class BlockListController extends ConfigEntityListController implements FormInte * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * 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, PluginManagerInterface $block_manager) { + parent::__construct($entity_info); $this->blockManager = $block_manager; } @@ -77,8 +71,6 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr 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('plugin.manager.block') ); } diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php b/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php index 9e0c7c2..f814869 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockAddController.php @@ -28,7 +28,7 @@ class BlockAddController extends ControllerBase { */ public function blockAddConfigureForm($plugin_id, $theme) { // Create a block entity. - $entity = $this->entityManager()->getStorageController('block')->create(array('plugin' => $plugin_id, 'theme' => $theme)); + $entity = $this->entityManager()->getDefinition('block')->getStorage()->create(array('plugin' => $plugin_id, 'theme' => $theme)); return $this->entityManager()->getForm($entity); } diff --git a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php index 2852970..5eea385 100644 --- a/core/modules/block/lib/Drupal/block/Controller/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/Controller/BlockListController.php @@ -29,7 +29,7 @@ class BlockListController extends EntityListController { */ public function listing($theme = NULL, Request $request = NULL) { $theme = $theme ?: $this->config('system.theme')->get('default'); - return $this->entityManager()->getListController('block')->render($theme, $request); + return $this->entityManager()->getDefinition('block')->getList()->render($theme, $request); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php index da6202e..0408b41 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockRenderOrderTest.php @@ -72,7 +72,7 @@ function testBlockRenderOrder() { $this->drupalGet(''); $test_content = $this->drupalGetContent(''); - $controller = $this->container->get('entity.manager')->getStorageController('block'); + $controller = \Drupal::entityManager()->getDefinition('block')->getStorage(); foreach ($controller->loadMultiple() as $return_block) { $id = $return_block->get('id'); if ($return_block_weight = $return_block->get('weight')) { diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php index 99977cb..3f21bb0 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockStorageUnitTest.php @@ -44,7 +44,7 @@ public static function getInfo() { protected function setUp() { parent::setUp(); - $this->controller = $this->container->get('entity.manager')->getStorageController('block'); + $this->controller = \Drupal::entityManager()->getDefinition('block')->getStorage(); } /** diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php b/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php index 3dbbf90..bfd4293 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTestBase.php @@ -66,7 +66,7 @@ function setUp() { 'sidebar_second', 'footer', ); - $block_storage = $this->container->get('entity.manager')->getStorageController('block'); + $block_storage = \Drupal::entityManager()->getDefinition('block')->getStorage(); $blocks = $block_storage->loadByProperties(array('theme' => \Drupal::config('system.theme')->get('default'))); foreach ($blocks as $block) { $block->delete(); diff --git a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php index 1cee4b8..24a4b9e 100644 --- a/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/Views/DisplayBlockTest.php @@ -141,7 +141,7 @@ protected function testDeleteBlockDisplay() { $this->assertBlockAppears($block_3); $this->assertBlockAppears($block_4); - $block_storage_controller = $this->container->get('entity.manager')->getStorageController('block'); + $block_storage_controller = \Drupal::entityManager()->getDefinition('block')->getStorage(); // Remove the block display, so both block entities from the first view // should both disappear. @@ -201,7 +201,7 @@ public function testViewsBlockForm() { $this->assertNoFieldById('edit-machine-name', 'views_block__test_view_block_1', 'The machine name is hidden on the views block form.'); // Save the block. $this->drupalPostForm(NULL, array(), t('Save block')); - $storage = $this->container->get('entity.manager')->getStorageController('block'); + $storage = \Drupal::entityManager()->getDefinition('block')->getStorage(); $block = $storage->load('views_block__test_view_block_block_1'); // This will only return a result if our new block has been created with the // expected machine name. diff --git a/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php b/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php index 69b0a1b..b7166b4 100644 --- a/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php +++ b/core/modules/block/tests/Drupal/block/Tests/BlockFormControllerTest.php @@ -31,9 +31,6 @@ public static function getInfo() { * @see \Drupal\block\BlockFormController::getUniqueMachineName() */ public function testGetUniqueMachineName() { - $block_storage = $this->getMockBuilder('Drupal\Core\Config\Entity\ConfigStorageController') - ->disableOriginalConstructor() - ->getMock(); $blocks = array(); $blocks['test'] = $this->getBlockMockWithMachineName('test'); @@ -60,12 +57,6 @@ public function testGetUniqueMachineName() { ->with('block', 'AND') ->will($this->returnValue($query)); - $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); - - $entity_manager->expects($this->any()) - ->method('getStorageController') - ->will($this->returnValue($block_storage)); - $language_manager = $this->getMockBuilder('Drupal\Core\Language\LanguageManager') ->disableOriginalConstructor() ->getMock(); @@ -74,7 +65,7 @@ public function testGetUniqueMachineName() { ->disableOriginalConstructor() ->getMock(); - $block_form_controller = new BlockFormController($entity_manager, $query_factory, $language_manager, $config_factory); + $block_form_controller = new BlockFormController($query_factory, $language_manager, $config_factory); // Ensure that the block with just one other instance gets the next available // name suggestion. diff --git a/core/modules/book/book.module b/core/modules/book/book.module index f49a3e2..46d4d40 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -129,7 +129,7 @@ function book_node_links_alter(array &$node_links, NodeInterface $node, array &$ if (isset($node->book['depth'])) { if ($context['view_mode'] == 'full' && node_is_page($node)) { $child_type = \Drupal::config('book.settings')->get('child_type'); - $access_controller = \Drupal::entityManager()->getAccessController('node'); + $access_controller = \Drupal::entityManager()->getDefinition('node')->getAccess(); if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_controller->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < MENU_MAX_DEPTH) { $links['book_add_child'] = array( 'title' => t('Add child page'), diff --git a/core/modules/book/lib/Drupal/book/BookBreadcrumbBuilder.php b/core/modules/book/lib/Drupal/book/BookBreadcrumbBuilder.php index 6dd54ff..0b68763 100644 --- a/core/modules/book/lib/Drupal/book/BookBreadcrumbBuilder.php +++ b/core/modules/book/lib/Drupal/book/BookBreadcrumbBuilder.php @@ -50,7 +50,7 @@ class BookBreadcrumbBuilder extends BreadcrumbBuilderBase { * The current user account. */ public function __construct(EntityManagerInterface $entity_manager, AccessManager $access_manager, AccountInterface $account) { - $this->menuLinkStorage = $entity_manager->getStorageController('menu_link'); + $this->menuLinkStorage = $entity_manager->getDefinition('menu_link')->getStorage(); $this->accessManager = $access_manager; $this->account = $account; } diff --git a/core/modules/book/lib/Drupal/book/BookExport.php b/core/modules/book/lib/Drupal/book/BookExport.php index c86e25c..4a3af8a 100644 --- a/core/modules/book/lib/Drupal/book/BookExport.php +++ b/core/modules/book/lib/Drupal/book/BookExport.php @@ -39,8 +39,9 @@ class BookExport { * The entity manager. */ public function __construct(EntityManagerInterface $entityManager) { - $this->nodeStorage = $entityManager->getStorageController('node'); - $this->viewBuilder = $entityManager->getViewBuilder('node'); + $node_entity_type = $entityManager->getDefinition('node'); + $this->nodeStorage = $node_entity_type->getStorage(); + $this->viewBuilder = $node_entity_type->getViewBuilder(); } /** diff --git a/core/modules/book/lib/Drupal/book/BookManager.php b/core/modules/book/lib/Drupal/book/BookManager.php index 9b415a8..11294ba 100644 --- a/core/modules/book/lib/Drupal/book/BookManager.php +++ b/core/modules/book/lib/Drupal/book/BookManager.php @@ -101,7 +101,7 @@ protected function loadBooks() { $query->addMetaData('base_table', 'book'); $book_links = $query->execute(); - $nodes = $this->entityManager->getStorageController('node')->loadMultiple($nids); + $nodes = $this->entityManager->getDefinition('node')->getStorage()->loadMultiple($nids); foreach ($book_links as $link) { $nid = $link['nid']; @@ -330,7 +330,7 @@ public function updateOutline(NodeInterface $node) { } $node->book = $this->entityManager - ->getStorageController('menu_link')->create($node->book); + ->getDefinition('menu_link')->getStorage()->create($node->book); if ($node->book->save()) { if ($new) { // Insert new. diff --git a/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php index 07beef0..cdaff81 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php @@ -64,8 +64,8 @@ public static function create(ContainerInterface $container) { $entity_manager = $container->get('entity.manager'); return new static( $container->get('cache.menu'), - $entity_manager->getStorageController('node'), - $entity_manager->getStorageController('menu_link') + $entity_manager->getDefinition('node')->getStorage(), + $entity_manager->getDefinition('menu_link')->getStorage() ); } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 0fce7ec..d4e8517 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -248,10 +248,10 @@ function comment_field_instance_create(FieldInstanceInterface $instance) { */ function comment_field_instance_update(FieldInstanceInterface $instance) { if ($instance->getType() == 'comment') { - \Drupal::entityManager()->getViewBuilder($instance->entity_type)->resetCache(); + \Drupal::entityManager()->getDefinition($instance->entity_type)->getViewBuilder()->resetCache(); // Comment field settings also affects the rendering of *comment* entities, // not only the *commented* entities. - \Drupal::entityManager()->getViewBuilder('comment')->resetCache(); + \Drupal::entityManager()->getDefinition('comment')->getViewBuilder()->resetCache(); } } @@ -1002,7 +1002,7 @@ function comment_node_update_index(EntityInterface $node, $langcode) { // edit could change the security situation so it is not safe to index the // comments. $index_comments = TRUE; - $roles = \Drupal::entityManager()->getStorageController('user_role')->loadMultiple(); + $roles = \Drupal::entityManager()->getDefinition('user_role')->getStorage()->loadMultiple(); $authenticated_can_access = $roles[DRUPAL_AUTHENTICATED_RID]->hasPermission('access comments'); foreach ($roles as $rid => $role) { if ($role->hasPermission('search content') && !$role->hasPermission('access comments')) { diff --git a/core/modules/comment/lib/Drupal/comment/CommentBreadcrumbBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentBreadcrumbBuilder.php index aa41c41..477f652 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentBreadcrumbBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentBreadcrumbBuilder.php @@ -51,7 +51,7 @@ public function build(array $attributes) { $breadcrumb[] = $this->l($this->t('Home'), ''); $entity = $this->entityManager - ->getStorageController($attributes['entity_type']) + ->getDefinition($attributes['entity_type'])->getStorage() ->load($attributes['entity_id']); $uri = $entity->uri(); $breadcrumb[] = l($entity->label(), $uri['path'], $uri['options']); diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index 3f88b51..dcfb46a 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -78,7 +78,7 @@ protected function init(array &$form_state) { */ public function form(array $form, array &$form_state) { $comment = $this->entity; - $entity = $this->entityManager->getStorageController($comment->entity_type->value)->load($comment->entity_id->value); + $entity = $this->entityManager->getDefinition($comment->entity_type->value)->getStorage()->load($comment->entity_id->value); $field_name = $comment->field_name->value; $instance = $this->fieldInfo->getInstance($entity->entityType(), $entity->bundle(), $field_name); @@ -231,7 +231,7 @@ public function form(array $form, array &$form_state) { protected function actions(array $form, array &$form_state) { $element = parent::actions($form, $form_state); $comment = $this->entity; - $entity = $this->entityManager->getStorageController($comment->entity_type->value)->load($comment->entity_id->value); + $entity = $this->entityManager->getDefinition($comment->entity_type->value)->getStorage()->load($comment->entity_id->value); $instance = $this->fieldInfo->getInstance($comment->entity_type->value, $entity->bundle(), $comment->field_name->value); $preview_mode = $instance->getSetting('preview'); @@ -269,7 +269,7 @@ public function validate(array $form, array &$form_state) { if (!empty($form_state['values']['cid'])) { // Verify the name in case it is being changed from being anonymous. - $accounts = $this->entityManager->getStorageController('user')->loadByProperties(array('name' => $form_state['values']['name'])); + $accounts = $this->entityManager->getDefinition('user')->getStorage()->loadByProperties(array('name' => $form_state['values']['name'])); $account = reset($accounts); $form_state['values']['uid'] = $account ? $account->id() : 0; @@ -286,7 +286,7 @@ public function validate(array $form, array &$form_state) { // author of this comment was an anonymous user, verify that no registered // user with this name exists. if ($form_state['values']['name']) { - $accounts = $this->entityManager->getStorageController('user')->loadByProperties(array('name' => $form_state['values']['name'])); + $accounts = $this->entityManager->getDefinition('user')->getStorage()->loadByProperties(array('name' => $form_state['values']['name'])); if (!empty($accounts)) { $this->setFormError('name', $form_state, $this->t('The name you used belongs to a registered user.')); } @@ -411,6 +411,6 @@ public function save(array $form, array &$form_state) { // Clear the block and page caches so that anonymous users see the comment // they have posted. Cache::invalidateTags(array('content' => TRUE)); - $this->entityManager->getViewBuilder($entity->entityType())->resetCache(array($entity)); + $this->entityManager->getDefinition($entity->entityType())->getViewBuilder()->resetCache(array($entity)); } } diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index 9bca3c5..7225189 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -48,7 +48,7 @@ public function __construct(FieldInfo $field_info, EntityManagerInterface $entit */ public function getParentEntityUri(CommentInterface $comment) { return $this->entityManager - ->getStorageController($comment->entity_type->value) + ->getDefinition($comment->entity_type->value)->getStorage() ->load($comment->entity_id->value) ->uri(); } @@ -90,7 +90,7 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', // Make sure the field doesn't already exist. if (!$this->fieldInfo->getField($entity_type, $field_name)) { // Add a default comment field for existing node comments. - $field = $this->entityManager->getStorageController('field_entity')->create(array( + $field = $this->entityManager->getDefinition('field_entity')->getStorage()->create(array( 'entity_type' => $entity_type, 'name' => $field_name, 'type' => 'comment', @@ -101,7 +101,7 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', } // Make sure the instance doesn't already exist. if (!$this->fieldInfo->getInstance($entity_type, $bundle, $field_name)) { - $instance = $this->entityManager->getStorageController('field_instance')->create(array( + $instance = $this->entityManager->getDefinition('field_instance')->getStorage()->create(array( 'label' => 'Comment settings', 'description' => '', 'field_name' => $field_name, @@ -145,9 +145,9 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', */ public function addBodyField($entity_type, $field_name) { // Create the field if needed. - $field = $this->entityManager->getStorageController('field_entity')->load('comment.comment_body'); + $field = $this->entityManager->getDefinition('field_entity')->getStorage()->load('comment.comment_body'); if (!$field) { - $field = $this->entityManager->getStorageController('field_entity')->create(array( + $field = $this->entityManager->getDefinition('field_entity')->getStorage()->create(array( 'name' => 'comment_body', 'type' => 'text_long', 'entity_type' => 'comment', @@ -157,11 +157,11 @@ public function addBodyField($entity_type, $field_name) { // Create the instance if needed, field name defaults to 'comment'. $comment_bundle = $entity_type . '__' . $field_name; $field_instance = $this->entityManager - ->getStorageController('field_instance') + ->getDefinition('field_instance')->getStorage() ->load("comment.$comment_bundle.comment_body"); if (!$field_instance) { // Attaches the body field by default. - $field_instance = $this->entityManager->getStorageController('field_instance')->create(array( + $field_instance = $this->entityManager->getDefinition('field_instance')->getStorage()->create(array( 'field_name' => 'comment_body', 'label' => 'Comment', 'entity_type' => 'comment', diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index 7dd6517..782c200 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -99,7 +99,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang foreach ($entities as $entity) { $uids[] = $entity->uid->target_id; } - $this->entityManager->getStorageController('user')->loadMultiple(array_unique($uids)); + $this->entityManager->getDefinition('user')->getStorage()->loadMultiple(array_unique($uids)); parent::buildContent($entities, $displays, $view_mode, $langcode); @@ -112,7 +112,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang // Load entities in bulk. This is more performant than using // $comment->entity_id->value as we can load them in bulk per type. foreach ($commented_entity_ids as $entity_type => $entity_ids) { - $commented_entities[$entity_type] = $this->entityManager->getStorageController($entity_type)->loadMultiple($entity_ids); + $commented_entities[$entity_type] = $this->entityManager->getDefinition($entity_type)->getStorage()->loadMultiple($entity_ids); } foreach ($entities as $entity) { @@ -273,7 +273,7 @@ protected function alterBuild(array &$build, EntityInterface $comment, EntityVie parent::alterBuild($build, $comment, $display, $view_mode, $langcode); if (empty($comment->in_preview)) { $prefix = ''; - $commented_entity = $this->entityManager->getStorageController($comment->entity_type->value)->load($comment->entity_id->value); + $commented_entity = $this->entityManager->getDefinition($comment->entity_type->value)->getStorage()->load($comment->entity_id->value); $instance = $this->fieldInfo->getInstance($commented_entity->entityType(), $commented_entity->bundle(), $comment->field_name->value); $is_threaded = isset($comment->divs) && $instance->getSetting('default_mode') == COMMENT_MODE_THREADED; diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 15f09a7..2b88840 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -119,7 +119,7 @@ public function commentApprove(CommentInterface $comment) { * The comment listing set to the page on which the comment appears. */ public function commentPermalink(Request $request, CommentInterface $comment) { - if ($entity = $this->entityManager()->getStorageController($comment->entity_type->value)->load($comment->entity_id->value)) { + if ($entity = $this->entityManager()->getDefinition($comment->entity_type->value)->getStorage()->load($comment->entity_id->value)) { // Check access permissions for the entity. if (!$entity->access('view')) { throw new AccessDeniedHttpException(); @@ -205,10 +205,11 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_ // Check if entity and field exists. $fields = $this->commentManager->getFields($entity_type); - if (empty($fields[$field_name]) || !($entity = $this->entityManager()->getStorageController($entity_type)->load($entity_id))) { + if (empty($fields[$field_name]) || !($entity = $this->entityManager()->getDefinition($entity_type)->getStorage()->load($entity_id))) { throw new NotFoundHttpException(); } + $comment_entity_type = $this->entityManager()->getDefinition('comment'); $account = $this->currentUser(); $uri = $entity->uri(); $build = array(); @@ -235,14 +236,14 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_ return new RedirectResponse($this->urlGenerator()->generateFromPath($uri['path'], array('absolute' => TRUE))); } // Load the parent comment. - $comment = $this->entityManager()->getStorageController('comment')->load($pid); + $comment = $comment_entity_type->getStorage()->load($pid); // Check if the parent comment is published and belongs to the entity. if (($comment->status->value == CommentInterface::NOT_PUBLISHED) || ($comment->entity_id->value != $entity->id())) { drupal_set_message($this->t('The comment you are replying to does not exist.'), 'error'); return new RedirectResponse($this->urlGenerator()->generateFromPath($uri['path'], array('absolute' => TRUE))); } // Display the parent comment. - $build['comment_parent'] = $this->entityManager()->getViewBuilder('comment')->view($comment); + $build['comment_parent'] = $comment_entity_type->getViewBuilder()->view($comment); } // The comment is in response to a entity. @@ -251,7 +252,7 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_ // redirect loop. $entity->{$field_name}->status = COMMENT_HIDDEN; // Render array of the entity full view mode. - $build['commented_entity'] = $this->entityManager()->getViewBuilder($entity->entityType())->view($entity, 'full'); + $build['commented_entity'] = $this->entityManager()->getDefinition($entity->entityType())->getViewBuilder()->view($entity, 'full'); unset($build['commented_entity']['#cache']); $entity->{$field_name}->status = $status; } @@ -261,7 +262,7 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_ } // Show the actual reply box. - $comment = $this->entityManager()->getStorageController('comment')->create(array( + $comment = $comment_entity_type->getStorage()->create(array( 'entity_id' => $entity->id(), 'pid' => $pid, 'entity_type' => $entity->entityType(), diff --git a/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php b/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php index 07c6d54..f8eb469 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php +++ b/core/modules/comment/lib/Drupal/comment/Form/CommentAdminOverview.php @@ -86,7 +86,7 @@ public function __construct(EntityManager $entity_manager, CommentStorageControl public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager'), - $container->get('entity.manager')->getStorageController('comment'), + $container->get('entity.manager')->getDefinition('comment')->getStorage(), $container->get('entity.query'), $container->get('date'), $container->get('module_handler') @@ -186,7 +186,7 @@ public function buildForm(array $form, array &$form_state, $type = 'new') { } foreach ($commented_entity_ids as $entity_type => $ids) { - $commented_entities[$entity_type] = $this->entityManager->getStorageController($entity_type)->loadMultiple($ids); + $commented_entities[$entity_type] = $this->entityManager->getDefinition($entity_type)->getStorage()->loadMultiple($ids); } foreach ($comments as $comment) { diff --git a/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php b/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php index b791b30..71a8b82 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php +++ b/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php @@ -48,7 +48,7 @@ public function __construct(CommentStorageControllerInterface $comment_storage) */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('comment') + $container->get('entity.manager')->getDefinition('comment')->getStorage() ); } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index b6ce094..fa1e12e 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -61,6 +61,8 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { + /** @var $comment_entity_type \Drupal\Core\Entity\EntityTypeInterface */ + $comment_entity_type = $container->get('entity.manager')->getDefinition('comment'); return new static( $plugin_id, $plugin_definition, @@ -69,8 +71,8 @@ public static function create(ContainerInterface $container, array $configuratio $configuration['label'], $configuration['view_mode'], $container->get('current_user'), - $container->get('entity.manager')->getStorageController('comment'), - $container->get('entity.manager')->getViewBuilder('comment') + $comment_entity_type->getStorage(), + $comment_entity_type->getViewBuilder() ); } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Link.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Link.php index 502566f..4627f61 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Link.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Link.php @@ -116,7 +116,7 @@ protected function renderLink($data, ResultRow $values) { elseif ($this->options['link_to_node']) { $entity_id = $comment->entity_id; $entity_type = $comment->entity_type; - $entity = $this->entityManager->getStorageController($entity_type)->load($entity_id); + $entity = $this->entityManager->getDefinition($entity_type)->getStorage()->load($entity_id); $uri = $entity->uri(); $this->options['alter']['path'] = $uri['path']; } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php index bda6e04..3dddf55 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php @@ -307,7 +307,7 @@ function testCommentFunctionality() { )); // We've changed role permissions, so need to reset render cache. // @todo Revisit after https://drupal.org/node/2099105 - \Drupal::entityManager()->getViewBuilder('entity_test')->resetCache(array($this->entity)); + \Drupal::entityManager()->getDefinition('entity_test')->getViewBuilder()->resetCache(array($this->entity)); $this->drupalGet('entity_test/' . $this->entity->id()); $this->assertPattern('@]*>Comments@', 'Comments were displayed.'); $this->assertLink('Log in', 0, 'Link to log in was found.'); @@ -326,7 +326,7 @@ function testCommentFunctionality() { )); // We've changed role permissions, so need to reset render cache. // @todo Revisit after https://drupal.org/node/2099105 - \Drupal::entityManager()->getViewBuilder('entity_test')->resetCache(array($this->entity)); + \Drupal::entityManager()->getDefinition('entity_test')->getViewBuilder()->resetCache(array($this->entity)); $this->drupalGet('entity_test/' . $this->entity->id()); $this->assertNoPattern('@]*>Comments@', 'Comments were not displayed.'); $this->assertFieldByName('subject', '', 'Subject field found.'); diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSingleExportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigSingleExportForm.php index 2f146c6..56bc7cd 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigSingleExportForm.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigSingleExportForm.php @@ -167,7 +167,7 @@ protected function findConfiguration($config_type) { ); // For a given entity type, load all entities. if ($config_type && $config_type !== 'system.simple') { - $entity_storage = $this->entityManager->getStorageController($config_type); + $entity_storage = $this->entityManager->getDefinition($config_type)->getStorage(); foreach ($entity_storage->loadMultiple() as $entity) { $entity_id = $entity->id(); $label = $entity->label() ?: $entity_id; diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php index b89f68b..6903b51 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php @@ -181,7 +181,7 @@ public function validateForm(array &$form, array &$form_state) { if ($form_state['values']['config_type'] !== 'system.simple') { $definition = $this->entityManager->getDefinition($form_state['values']['config_type']); $id_key = $definition->getKey('id'); - $entity_storage = $this->entityManager->getStorageController($form_state['values']['config_type']); + $entity_storage = $this->entityManager->getDefinition($form_state['values']['config_type'])->getStorage(); // If an entity ID was not specified, set an error. if (!isset($data[$id_key])) { $this->setFormError('import', $form_state, $this->t('Missing ID key "@id_key" for this @entity_type import.', array('@id_key' => $id_key, '@entity_type' => $definition->getLabel()))); @@ -234,7 +234,7 @@ public function submitForm(array &$form, array &$form_state) { else { try { $entity = $this->entityManager - ->getStorageController($this->data['config_type']) + ->getDefinition($this->data['config_type'])->getStorage() ->create($this->data['import']); $entity->save(); drupal_set_message($this->t('The @entity_type %label was imported.', array('@entity_type' => $entity->entityType(), '%label' => $entity->label()))); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php index d1dc721..dc656f7 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityListTest.php @@ -35,11 +35,11 @@ public static function getInfo() { * Tests entity list controller methods. */ function testList() { - $controller = $this->container->get('entity.manager') - ->getListController('config_test'); + $entity_manager = \Drupal::entityManager(); + $controller = $entity_manager->getDefinition('config_test')->getList(); - // Test getStorageController() method. - $this->assertTrue($controller->getStorageController() instanceof EntityStorageControllerInterface, 'EntityStorageController instance in storage.'); + // Test getStorage() method. + $this->assertTrue($controller->getDefinition()->getStorage() instanceof EntityStorageControllerInterface, 'EntityStorageController instance in storage.'); // Get a list of ConfigTest entities and confirm that it contains the // ConfigTest entity provided by the config_test module. @@ -99,7 +99,7 @@ function testList() { $actual_items = $controller->buildRow($entity); $this->assertIdentical($expected_items, $actual_items, 'Return value from buildRow matches expected.'); // Test sorting. - $storage_controller = $controller->getStorageController(); + $storage_controller = $controller->getDefinition()->getStorage(); $entity = $storage_controller->create(array( 'id' => 'alpha', 'label' => 'Alpha', @@ -123,8 +123,7 @@ function testList() { // Test that config entities that do not support status, do not have // enable/disable operations. - $controller = $this->container->get('entity.manager') - ->getListController('config_test_no_status'); + $controller = $entity_manager->getDefinition('config_test_no_status')->getList(); $list = $controller->load(); $entity = $list['default']; diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php index 262fd46..fb548f9 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityUnitTest.php @@ -42,7 +42,7 @@ public static function getInfo() { */ protected function setUp() { parent::setUp(); - $this->storage = $this->container->get('entity.manager')->getStorageController('config_test'); + $this->storage = \Drupal::entityManager()->getDefinition('config_test')->getStorage(); } /** diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php index 564218a..7563e9b 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php @@ -34,7 +34,7 @@ public static function getInfo() { * Tests importing a single configuration file. */ public function testImport() { - $storage = \Drupal::entityManager()->getStorageController('config_test'); + $storage = \Drupal::entityManager()->getDefinition('config_test')->getStorage(); $uuid = \Drupal::service('uuid'); $this->drupalLogin($this->drupalCreateUser(array('import configuration'))); @@ -143,7 +143,7 @@ public function testExport() { $this->drupalGet('admin/config/development/configuration/single/export/date_format/fallback'); $this->assertFieldByXPath('//select[@name="config_name"]//option', t('Fallback date format'), 'The fallback date format config entity is selected when specified in the URL.'); - $fallback_date = \Drupal::entityManager()->getStorageController('date_format')->load('fallback'); + $fallback_date = \Drupal::entityManager()->getDefinition('date_format')->getStorage()->load('fallback'); $data = \Drupal::service('config.storage')->encode($fallback_date->getExportProperties()); $this->assertFieldByXPath('//textarea[@name="export"]', $data, 'The fallback date format config entity export code is displayed.'); } 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..40e7449 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 @@ -9,9 +9,7 @@ use Drupal\Component\Utility\String; 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 +26,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) { + parent::__construct($entity_info); $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..68b8e76 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 @@ -11,9 +11,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Entity\EntityInterface; 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; @@ -66,8 +64,6 @@ class ConfigTranslationFieldInstanceListController extends ConfigTranslationEnti public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info, array $definition = array()) { return new static( $entity_info, - $container->get('entity.manager')->getStorageController($entity_info->id()), - $container->get('module_handler'), $container->get('entity.manager'), $definition ); @@ -78,17 +74,13 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * 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, EntityManagerInterface $entity_manager, array $definition) { + parent::__construct($entity_info); $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..77d0fac 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,7 @@ 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->moduleHandler(), $this->entityManager(), $this->mapperDefinition); $build = $controller->render(); $build['#title'] = $this->mapper->getTypeLabel(); return $build; diff --git a/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php b/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php index ff5f71d..46d4da2 100644 --- a/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php +++ b/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php @@ -70,7 +70,7 @@ public function contactSitePage(CategoryInterface $contact_category = NULL) { // Use the default category if no category has been passed. if (empty($contact_category)) { $contact_category = $this->entityManager() - ->getStorageController('contact_category') + ->getDefinition('contact_category')->getStorage() ->load($this->config('contact.settings')->get('default_category')); // If there are no categories, do not display the form. if (empty($contact_category)) { @@ -86,7 +86,7 @@ public function contactSitePage(CategoryInterface $contact_category = NULL) { } $message = $this->entityManager() - ->getStorageController('contact_message') + ->getDefinition('contact_message')->getStorage() ->create(array( 'category' => $contact_category->id(), )); @@ -111,7 +111,7 @@ public function contactPersonalPage(UserInterface $user) { $this->contactFloodControl(); } - $message = $this->entityManager()->getStorageController('contact_message')->create(array( + $message = $this->entityManager()->getDefinition('contact_message')->getStorage()->create(array( 'category' => 'personal', 'recipient' => $user->id(), )); diff --git a/core/modules/contact/lib/Drupal/contact/Tests/MessageEntityTest.php b/core/modules/contact/lib/Drupal/contact/Tests/MessageEntityTest.php index fd5300b..3409787 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/MessageEntityTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/MessageEntityTest.php @@ -40,7 +40,7 @@ protected function setUp() { * Test some of the methods. */ public function testMessageMethods() { - $message_storage = $this->container->get('entity.manager')->getStorageController('contact_message'); + $message_storage = \Drupal::entityManager()->getDefinition('contact_message')->getStorage(); $message = $message_storage->create(array('category' => 'feedback')); // Check for empty values first. 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..416410c 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 @@ -41,11 +41,12 @@ public function __construct(EntityManagerInterface $manager) { */ public function access(Route $route, Request $request, AccountInterface $account) { $entity_type = $request->attributes->get('_entity_type'); + /** @var $entity \Drupal\Core\Entity\EntityInterface */ 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()); + $entity_info = $entity->entityInfo(); + $controller = $entity_info->getControllerInstance($entity_info->getController('translation')); // Load translation. $translations = $entity->getTranslationLanguages(); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php index 4efde31..6d7551f 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php @@ -48,7 +48,7 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode // If the entity language is being changed there is nothing to synchronize. $entity_type = $entity->entityType(); - $entity_unchanged = isset($entity->original) ? $entity->original : $this->entityManager->getStorageController($entity_type)->loadUnchanged($entity->id()); + $entity_unchanged = isset($entity->original) ? $entity->original : $this->entityManager->getDefinition($entity_type)->getStorage()->loadUnchanged($entity->id()); if ($entity->getUntranslated()->language()->id != $entity_unchanged->getUntranslated()->language()->id) { return; } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php index 6e18d0f..ebdcd7c 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php @@ -210,7 +210,7 @@ protected function createEntity($values, $langcode, $bundle_name = NULL) { if ($bundle_key = $info->getKey('bundle')) { $entity_values[$bundle_key] = $bundle_name ?: $this->bundle; } - $controller = $this->container->get('entity.manager')->getStorageController($this->entityType); + $controller = \Drupal::entityManager()->getDefinition($this->entityType)->getStorage(); if (!($controller instanceof FieldableDatabaseStorageController)) { foreach ($values as $property => $value) { if (is_array($value)) { diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldFormatter/DatetimeDefaultFormatter.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldFormatter/DatetimeDefaultFormatter.php index 1a235dc..9a2147a 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldFormatter/DatetimeDefaultFormatter.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldFormatter/DatetimeDefaultFormatter.php @@ -85,7 +85,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration['label'], $configuration['view_mode'], $container->get('date'), - $container->get('entity.manager')->getStorageController('date_format') + $container->get('entity.manager')->getDefinition('date_format')->getStorage() ); } diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldWidget/DatetimeDefaultWidget.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldWidget/DatetimeDefaultWidget.php index 9389a71..6072140 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldWidget/DatetimeDefaultWidget.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldWidget/DatetimeDefaultWidget.php @@ -38,7 +38,7 @@ public function __construct($plugin_id, array $plugin_definition, FieldDefinitio parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings); // @todo Inject this once https://drupal.org/node/2035317 is in. - $this->dateStorage = \Drupal::entityManager()->getStorageController('date_format'); + $this->dateStorage = \Drupal::entityManager()->getDefinition('date_format')->getStorage(); } /** diff --git a/core/modules/edit/lib/Drupal/edit/Access/EditEntityAccessCheck.php b/core/modules/edit/lib/Drupal/edit/Access/EditEntityAccessCheck.php index 827c06f..72e864d 100644 --- a/core/modules/edit/lib/Drupal/edit/Access/EditEntityAccessCheck.php +++ b/core/modules/edit/lib/Drupal/edit/Access/EditEntityAccessCheck.php @@ -67,7 +67,7 @@ protected function validateAndUpcastRequestAttributes(Request $request) { if (!$entity_type || !$this->entityManager->getDefinition($entity_type)) { throw new NotFoundHttpException(); } - $entity = $this->entityManager->getStorageController($entity_type)->load($entity_id); + $entity = $this->entityManager->getDefinition($entity_type)->getStorage()->load($entity_id); if (!$entity) { throw new NotFoundHttpException(); } diff --git a/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php b/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php index 9de7347..02eef99 100644 --- a/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php +++ b/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php @@ -67,7 +67,7 @@ protected function validateAndUpcastRequestAttributes(Request $request) { if (!$entity_type || !$this->entityManager->getDefinition($entity_type)) { throw new NotFoundHttpException(); } - $entity = $this->entityManager->getStorageController($entity_type)->load($entity_id); + $entity = $this->entityManager->getDefinition($entity_type)->getStorage()->load($entity_id); if (!$entity) { throw new NotFoundHttpException(); } diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php index 4621f94..51ecf23 100644 --- a/core/modules/edit/lib/Drupal/edit/EditController.php +++ b/core/modules/edit/lib/Drupal/edit/EditController.php @@ -148,7 +148,7 @@ public function metadata(Request $request) { if (!$entity_type || !$this->entityManager->getDefinition($entity_type)) { throw new NotFoundHttpException(); } - $entity = $this->entityManager->getStorageController($entity_type)->load($entity_id); + $entity = $this->entityManager->getDefinition($entity_type)->getStorage()->load($entity_id); if (!$entity) { throw new NotFoundHttpException(); } diff --git a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php index 1c356b2..f6b1917 100644 --- a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php +++ b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php @@ -64,7 +64,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('user.tempstore'), $container->get('module_handler'), - $container->get('entity.manager')->getStorageController('node_type') + $container->get('entity.manager')->getDefinition('node_type')->getStorage() ); } diff --git a/core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityAccessCheckTest.php b/core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityAccessCheckTest.php index 0d5ca57..17645ba 100644 --- a/core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityAccessCheckTest.php +++ b/core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityAccessCheckTest.php @@ -58,10 +58,6 @@ protected function setUp() { $this->entityStorageController = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface'); - $this->entityManager->expects($this->any()) - ->method('getStorageController') - ->will($this->returnValue($this->entityStorageController)); - $this->editAccessCheck = new EditEntityAccessCheck($this->entityManager); } @@ -145,10 +141,15 @@ public function testAccessWithNotExistingEntity() { $request->attributes->set('entity_type', 'entity_test'); $request->attributes->set('entity', 1); - $this->entityManager->expects($this->once()) + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->any()) + ->method('getStorage') + ->will($this->returnValue($this->entityStorageController)); + + $this->entityManager->expects($this->any()) ->method('getDefinition') - ->with('entity_test') - ->will($this->returnValue(array('id' => 'entity_test'))); + ->with($this->equalTo('entity_test')) + ->will($this->returnValue($entity_type)); $this->entityStorageController->expects($this->once()) ->method('load') diff --git a/core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityFieldAccessCheckTest.php b/core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityFieldAccessCheckTest.php index b9c847d..94dedcd 100644 --- a/core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityFieldAccessCheckTest.php +++ b/core/modules/edit/tests/Drupal/edit/Tests/Access/EditEntityFieldAccessCheckTest.php @@ -60,10 +60,6 @@ protected function setUp() { $this->entityStorageController = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface'); - $this->entityManager->expects($this->any()) - ->method('getStorageController') - ->will($this->returnValue($this->entityStorageController)); - $this->editAccessCheck = new EditEntityFieldAccessCheck($this->entityManager); } @@ -152,7 +148,7 @@ public function testAccessWithUndefinedEntityType() { $request = new Request(); $request->attributes->set('entity_type', 'non_valid'); - $this->entityManager->expects($this->once()) + $this->entityManager->expects($this->any()) ->method('getDefinition') ->with('non_valid') ->will($this->returnValue(NULL)); @@ -172,10 +168,15 @@ public function testAccessWithNotExistingEntity() { $request->attributes->set('entity_type', 'entity_test'); $request->attributes->set('entity', 1); - $this->entityManager->expects($this->once()) + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->any()) + ->method('getStorage') + ->will($this->returnValue($this->entityStorageController)); + + $this->entityManager->expects($this->any()) ->method('getDefinition') ->with('entity_test') - ->will($this->returnValue(array('id' => 'entity_test'))); + ->will($this->returnValue($entity_type)); $this->entityStorageController->expects($this->once()) ->method('load') diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index 310520c..8aa7334 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -146,8 +146,9 @@ public function save() { $return = parent::save(); // Reset the render cache for the target entity type. - if (\Drupal::entityManager()->hasController($this->targetEntityType, 'view_builder')) { - \Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache(); + $entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); + if ($entity_type->hasController('view_builder')) { + $entity_type->getViewBuilder()->resetCache(); } return $return; diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php index 8946534..f311ec2 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php @@ -9,9 +9,7 @@ use Drupal\Core\Config\Entity\ConfigEntityListController; 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; /** @@ -31,15 +29,11 @@ class EntityDisplayModeListController extends ConfigEntityListController { * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * 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, array $entity_info_complete) { + parent::__construct($entity_info); $this->entityInfoComplete = $entity_info_complete; } @@ -48,12 +42,9 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) { - $entity_manager = $container->get('entity.manager'); return new static( $entity_info, - $entity_manager->getStorageController($entity_info->id()), - $container->get('module_handler'), - $entity_manager->getDefinitions() + $container->get('entity.manager')->getDefinitions() ); } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php index e49373d..52c5cbb 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceAutocomplete.php @@ -76,7 +76,7 @@ public function getMatches($field, $instance, $entity_type, $entity_id = '', $pr $entity = NULL; if ($entity_id !== 'NULL') { - $entity = $this->entityManager->getStorageController($entity_type)->load($entity_id); + $entity = $this->entityManager->getDefinition($entity_type)->getStorage()->load($entity_id); if (!$entity || !$entity->access('view')) { throw new AccessDeniedHttpException(); } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php index 6ee2db4..6d8e75f 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php @@ -86,7 +86,7 @@ public function handleAutocomplete(Request $request, $type, $field_name, $entity throw new AccessDeniedHttpException(); } - $access_controller = $this->entityManager->getAccessController($entity_type); + $access_controller = $this->entityManager->getDefinition($entity_type)->getAccess(); if ($instance->getType() != 'entity_reference' || !$access_controller->fieldAccess('edit', $instance)) { throw new AccessDeniedHttpException(); } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php index 9623c43..fba35e6 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldType/ConfigurableEntityReferenceFieldItemList.php @@ -38,7 +38,7 @@ protected function getDefaultValue() { ->condition('uuid', $uuids, 'IN') ->execute(); $entities = \Drupal::entityManager() - ->getStorageController($target_type) + ->getDefinition($target_type)->getStorage() ->loadMultiple($entity_ids); foreach ($entities as $id => $entity) { @@ -80,7 +80,7 @@ public function defaultValuesFormSubmit(array $element, array &$form, array &$fo $ids[] = $properties['target_id']; } $entities = \Drupal::entityManager() - ->getStorageController($this->getFieldDefinition()->getSetting('target_type')) + ->getDefinition($this->getFieldDefinition()->getStorage()->getSetting('target_type')) ->loadMultiple($ids); foreach ($default_value as $delta => $properties) { diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php index 4621c5c..ed1a6f2 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php @@ -172,7 +172,7 @@ protected function createNewEntity($label, $uid) { $bundle_key = $entity_info->getKey('bundle'); $label_key = $entity_info->getKey('label'); - return $entity_manager->getStorageController($target_type)->create(array( + return $entity_manager->getDefinition($target_type)->getStorage()->create(array( $label_key => $label, $bundle_key => $bundle, 'uid' => $uid, diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc index 95af3a7..21122f9 100644 --- a/core/modules/field/field.purge.inc +++ b/core/modules/field/field.purge.inc @@ -109,7 +109,7 @@ function field_purge_batch($batch_size) { $ids->revision_id = $revision_id; $ids->entity_id = $entity_id; $entity = _field_create_entity_from_ids($ids); - \Drupal::entityManager()->getStorageController($entity_type)->onFieldItemsPurge($entity, $instance); + \Drupal::entityManager()->getDefinition($entity_type)->getStorage()->onFieldItemsPurge($entity, $instance); } } else { @@ -180,7 +180,7 @@ function field_purge_field($field) { $state->set('field.field.deleted', $deleted_fields); // Notify the storage layer. - \Drupal::entityManager()->getStorageController($field->entity_type)->onFieldPurge($field); + \Drupal::entityManager()->getDefinition($field->entity_type)->getStorage()->onFieldPurge($field); // Clear the cache. field_info_cache_clear(); diff --git a/core/modules/field/field.views.inc b/core/modules/field/field.views.inc index e9e65c4..702682e 100644 --- a/core/modules/field/field.views.inc +++ b/core/modules/field/field.views.inc @@ -68,7 +68,7 @@ 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) { + if ($entity_manager->getDefinition($field->entity_type)->getStorage() instanceof FieldableDatabaseStorageController) { return TRUE; } } diff --git a/core/modules/field/lib/Drupal/field/Entity/Field.php b/core/modules/field/lib/Drupal/field/Entity/Field.php index 6d5e68a..4f20b11 100644 --- a/core/modules/field/lib/Drupal/field/Entity/Field.php +++ b/core/modules/field/lib/Drupal/field/Entity/Field.php @@ -337,7 +337,7 @@ protected function preSaveNew(EntityStorageControllerInterface $storage_controll $this->settings += $field_type['settings']; // Notify the entity storage controller. - $entity_manager->getStorageController($this->entity_type)->onFieldCreate($this); + $entity_manager->getDefinition($this->entity_type)->getStorage()->onFieldCreate($this); } /** @@ -370,7 +370,7 @@ protected function preSaveUpdated(EntityStorageControllerInterface $storage_cont // Notify the storage controller. The controller can reject the definition // update as invalid by raising an exception, which stops execution before // the definition is written to config. - $entity_manager->getStorageController($this->entity_type)->onFieldUpdate($this); + $entity_manager->getDefinition($this->entity_type)->getStorage()->onFieldUpdate($this); } /** @@ -386,7 +386,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ */ public static function preDelete(EntityStorageControllerInterface $storage_controller, array $fields) { $state = \Drupal::state(); - $instance_controller = \Drupal::entityManager()->getStorageController('field_instance'); + $instance_controller = \Drupal::entityManager()->getDefinition('field_instance')->getStorage(); // Delete instances first. Note: when deleting a field through // FieldInstance::postDelete(), the instances have been deleted already, so @@ -429,7 +429,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont // Notify the storage. foreach ($fields as $field) { if (!$field->deleted) { - \Drupal::entityManager()->getStorageController($field->entity_type)->onFieldDelete($field); + \Drupal::entityManager()->getDefinition($field->entity_type)->getStorage()->onFieldDelete($field); } } diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php index 51eebbd..ba192bd 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstance.php @@ -342,14 +342,14 @@ public function getExportProperties() { * In case of failures at the configuration storage level. */ public function preSave(EntityStorageControllerInterface $storage_controller) { - $entity_manager = \Drupal::entityManager(); + $entity_storage = \Drupal::entityManager()->getDefinition($this->entity_type)->getStorage(); $field_type_manager = \Drupal::service('plugin.manager.field.field_type'); if ($this->isNew()) { // Set the default instance settings. $this->settings += $field_type_manager->getDefaultInstanceSettings($this->field->type); // Notify the entity storage controller. - $entity_manager->getStorageController($this->entity_type)->onInstanceCreate($this); + $entity_storage->onInstanceCreate($this); } else { // Some updates are always disallowed. @@ -365,7 +365,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) { // Set the default instance settings. $this->settings += $field_type_manager->getDefaultInstanceSettings($this->field->type); // Notify the entity storage controller. - $entity_manager->getStorageController($this->entity_type)->onInstanceUpdate($this); + $entity_storage->onInstanceUpdate($this); } } @@ -400,7 +400,7 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr * {@inheritdoc} */ public static function postDelete(EntityStorageControllerInterface $storage_controller, array $instances) { - $field_controller = \Drupal::entityManager()->getStorageController('field_entity'); + $field_controller = \Drupal::entityManager()->getDefinition('field_entity')->getStorage(); // Clear the cache upfront, to refresh the results of getBundles(). field_cache_clear(); @@ -408,7 +408,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont // Notify the entity storage controller. foreach ($instances as $instance) { if (!$instance->deleted) { - \Drupal::entityManager()->getStorageController($instance->entity_type)->onInstanceDelete($instance); + \Drupal::entityManager()->getDefinition($instance->entity_type)->getStorage()->onInstanceDelete($instance); } } diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php index ef25a51..56c962b 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php @@ -118,18 +118,18 @@ public function loadByProperties(array $conditions = array()) { if (isset($conditions['entity_type']) && isset($conditions['bundle']) && isset($conditions['field_name'])) { // Optimize for the most frequent case where we do have a specific ID. $id = $conditions['entity_type'] . '.' . $conditions['bundle'] . '.' . $conditions['field_name']; - $instances = $this->entityManager->getStorageController($this->entityType)->loadMultiple(array($id)); + $instances = $this->entityManager->getDefinition($this->entityType)->getStorage()->loadMultiple(array($id)); } else { // No specific ID, we need to examine all existing instances. - $instances = $this->entityManager->getStorageController($this->entityType)->loadMultiple(); + $instances = $this->entityManager->getDefinition($this->entityType)->getStorage()->loadMultiple(); } // Merge deleted instances (stored in state) if needed. if ($include_deleted) { $deleted_instances = $this->state->get('field.instance.deleted') ?: array(); foreach ($deleted_instances as $id => $config) { - $instances[$id] = $this->entityManager->getStorageController($this->entityType)->create($config); + $instances[$id] = $this->entityManager->getDefinition($this->entityType)->getStorage()->create($config); } } diff --git a/core/modules/field/lib/Drupal/field/FieldStorageController.php b/core/modules/field/lib/Drupal/field/FieldStorageController.php index a1f9716..d3fe537 100644 --- a/core/modules/field/lib/Drupal/field/FieldStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldStorageController.php @@ -100,18 +100,18 @@ public function loadByProperties(array $conditions = array()) { if (isset($conditions['entity_type']) && isset($conditions['field_name'])) { // Optimize for the most frequent case where we do have a specific ID. $id = $conditions['entity_type'] . $conditions['field_name']; - $fields = $this->entityManager->getStorageController($this->entityType)->loadMultiple(array($id)); + $fields = $this->entityManager->getDefinition($this->entityType)->getStorage()->loadMultiple(array($id)); } else { // No specific ID, we need to examine all existing fields. - $fields = $this->entityManager->getStorageController($this->entityType)->loadMultiple(); + $fields = $this->entityManager->getDefinition($this->entityType)->getStorage()->loadMultiple(); } // Merge deleted fields (stored in state) if needed. if ($include_deleted) { $deleted_fields = $this->state->get('field.field.deleted') ?: array(); foreach ($deleted_fields as $id => $config) { - $fields[$id] = $this->entityManager->getStorageController($this->entityType)->create($config); + $fields[$id] = $this->entityManager->getDefinition($this->entityType)->getStorage()->create($config); } } diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php index 6c6b350..6e488d7 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -172,7 +172,7 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o */ public function access(AccountInterface $account) { $base_table = $this->get_base_table(); - $access_controller = $this->entityManager->getAccessController($this->definition['entity_tables'][$base_table]); + $access_controller = $this->entityManager->getDefinition($this->definition['entity_tables'][$base_table])->getAccess(); return $access_controller->fieldAccess('view', $this->field_info, $account); } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index ccd6cd1..2f92688 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -261,7 +261,7 @@ function testFieldAttachCache() { $this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on insert'); // Load, and check that a cache entry is present with the expected values. - $controller = $this->container->get('entity.manager')->getStorageController($entity->entityType()); + $controller = \Drupal::entityManager()->getDefinition($entity->entityType()->getStorage()); $controller->resetCache(); $controller->load($entity->id()); $cache = cache('field')->get($cid); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php index 6d3ecb7..0c412d4 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php @@ -70,7 +70,7 @@ function testFieldAttachSaveLoad() { $values[$current_revision] = $current_values; } - $storage_controller = $this->container->get('entity.manager')->getStorageController($entity_type); + $storage_controller = \Drupal::entityManager()->getDefinition($entity_type)->getStorage(); $storage_controller->resetCache(); $entity = $storage_controller->load($entity_id); // Confirm current revision loads the correct data. @@ -156,7 +156,7 @@ function testFieldAttachLoadMultiple() { } // Check that a single load correctly loads field values for both entities. - $controller = $this->container->get('entity.manager')->getStorageController($entity->entityType()); + $controller = \Drupal::entityManager()->getDefinition($entity->entityType()->getStorage()); $controller->resetCache(); $entities = $controller->loadMultiple(); foreach ($entities as $index => $entity) { @@ -267,7 +267,7 @@ function testFieldAttachDelete() { $entity->setNewRevision(); $entity->save(); $vids[] = $entity->getRevisionId(); - $controller = $this->container->get('entity.manager')->getStorageController($entity->entityType()); + $controller = \Drupal::entityManager()->getDefinition($entity->entityType()->getStorage()); $controller->resetCache(); // Confirm each revision loads @@ -334,7 +334,7 @@ function testEntityCreateRenameBundle() { $this->assertIdentical($this->instance->bundle, $new_bundle, "Bundle name has been updated in the instance."); // Verify the field data is present on load. - $controller = $this->container->get('entity.manager')->getStorageController($entity->entityType()); + $controller = \Drupal::entityManager()->getDefinition($entity->entityType()->getStorage()); $controller->resetCache(); $entity = $controller->load($entity->id()); $this->assertEqual(count($entity->{$this->field_name}), $cardinality, "Bundle name has been updated in the field storage"); @@ -389,7 +389,7 @@ function testEntityDeleteBundle() { entity_test_delete_bundle($this->instance->bundle, $entity_type); // Verify no data gets loaded - $controller = $this->container->get('entity.manager')->getStorageController($entity->entityType()); + $controller = \Drupal::entityManager()->getDefinition($entity->entityType()->getStorage()); $controller->resetCache(); $entity= $controller->load($entity->id()); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php index 9eaa8d0..cfabce3 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInstanceCrudTest.php @@ -212,7 +212,7 @@ function testDeleteFieldInstanceCrossDeletion() { $instance->save(); $instance_2 = entity_create('field_instance', $instance_definition_2); $instance_2->save(); - $instance_controller = $this->container->get('entity.manager')->getStorageController('field_instance'); + $instance_controller = \Drupal::entityManager()->getDefinition('field_instance')->getStorage(); $instance_controller->delete(array($instance, $instance_2)); $this->assertFalse(field_info_field('entity_test', $field->name)); } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php index d9a776b..1083721 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php @@ -109,7 +109,7 @@ function createFieldWithInstance($suffix = '', $entity_type = 'entity_test', $bu */ protected function entitySaveReload(EntityInterface $entity) { $entity->save(); - $controller = $this->container->get('entity.manager')->getStorageController($entity->entityType()); + $controller = \Drupal::entityManager()->getDefinition($entity->entityType()->getStorage()); $controller->resetCache(); return $controller->load($entity->id()); } diff --git a/core/modules/field/lib/Drupal/field/Tests/FormTest.php b/core/modules/field/lib/Drupal/field/Tests/FormTest.php index 81ec2ff..e996a59 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FormTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FormTest.php @@ -151,7 +151,7 @@ function testFieldFormSingle() { ); $this->drupalPostForm(NULL, $edit, t('Save')); $this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated'); - $this->container->get('entity.manager')->getStorageController('entity_test')->resetCache(array($id)); + \Drupal::entityManager()->getDefinition('entity_test')->getStorage()->resetCache(array($id)); $entity = entity_load('entity_test', $id); $this->assertEqual($entity->{$field_name}->value, $value, 'Field value was updated'); @@ -164,7 +164,7 @@ function testFieldFormSingle() { ); $this->drupalPostForm('entity_test/manage/' . $id, $edit, t('Save')); $this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated'); - $this->container->get('entity.manager')->getStorageController('entity_test')->resetCache(array($id)); + \Drupal::entityManager()->getDefinition('entity_test')->getStorage()->resetCache(array($id)); $entity = entity_load('entity_test', $id); $this->assertTrue($entity->{$field_name}->isEmpty(), 'Field was emptied'); } @@ -568,7 +568,7 @@ function testFieldFormAccess() { $this->drupalPostForm($entity_type . '/manage/' . $id, $edit, t('Save')); // Check that the new revision has the expected values. - $this->container->get('entity.manager')->getStorageController($entity_type)->resetCache(array($id)); + \Drupal::entityManager()->getDefinition($entity_type)->getStorage()->resetCache(array($id)); $entity = entity_load($entity_type, $id); $this->assertEqual($entity->$field_name_no_access->value, 99, 'New revision has the expected value for the field with no edit access.'); $this->assertEqual($entity->$field_name->value, 2, 'New revision has the expected value for the field with edit access.'); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php b/core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php index ece0c63..34e59e0 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php @@ -51,7 +51,7 @@ public function access(Route $route, Request $request, AccountInterface $account if (!$form_mode || $form_mode == 'default') { $visibility = TRUE; } - elseif ($entity_display = $this->entityManager->getStorageController('entity_form_display')->load($entity_type . '.' . $bundle . '.' . $form_mode)) { + elseif ($entity_display = $this->entityManager->getDefinition('entity_form_display')->getStorage()->load($entity_type . '.' . $bundle . '.' . $form_mode)) { $visibility = $entity_display->status(); } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php b/core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php index 393fa7b..b2df39e 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php @@ -51,7 +51,7 @@ public function access(Route $route, Request $request, AccountInterface $account if (!$view_mode || $view_mode == 'default') { $visibility = TRUE; } - elseif ($entity_display = $this->entityManager->getStorageController('entity_display')->load($entity_type . '.' . $bundle . '.' . $view_mode)) { + elseif ($entity_display = $this->entityManager->getDefinition('entity_display')->getStorage()->load($entity_type . '.' . $bundle . '.' . $view_mode)) { $visibility = $entity_display->status(); } 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..8681f1e 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); $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/field_ui/lib/Drupal/field_ui/FieldOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php index c5832e8..724f10e 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -399,8 +399,8 @@ public function submitForm(array &$form, array &$form_state) { // Create the field and instance. try { - $this->entityManager->getStorageController('field_entity')->create($field)->save(); - $new_instance = $this->entityManager->getStorageController('field_instance')->create($instance); + $this->entityManager->getDefinition('field_entity')->getStorage()->create($field)->save(); + $new_instance = $this->entityManager->getDefinition('field_instance')->getStorage()->create($instance); $new_instance->save(); // Make sure the field is displayed in the 'default' form mode (using @@ -447,7 +447,7 @@ public function submitForm(array &$form, array &$form_state) { ); try { - $new_instance = $this->entityManager->getStorageController('field_instance')->create($instance); + $new_instance = $this->entityManager->getDefinition('field_instance')->getStorage()->create($instance); $new_instance->save(); // Make sure the field is displayed in the 'default' form mode (using @@ -513,7 +513,7 @@ protected function getExistingFieldOptions() { // Load the instances and build the list of options. if ($instance_ids) { $field_types = $this->fieldTypeManager->getDefinitions(); - $instances = $this->entityManager->getStorageController('field_instance')->loadMultiple($instance_ids); + $instances = $this->entityManager->getDefinition('field_instance')->getStorage()->loadMultiple($instance_ids); foreach ($instances as $instance) { // Do not show: // - locked fields, diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 892b214..3d5d1f3 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -383,7 +383,7 @@ function file_validate_size(File $file, $file_limit = 0, $user_limit = 0) { } // Save a query by only calling spaceUsed() when a limit is provided. - if ($user_limit && (\Drupal::entityManager()->getStorageController('file')->spaceUsed($user->id()) + $file->getSize()) > $user_limit) { + if ($user_limit && (\Drupal::entityManager()->getDefinition('file')->getStorage()->spaceUsed($user->id()) + $file->getSize()) > $user_limit) { $errors[] = t('The file is %filesize which would exceed your disk quota of %quota.', array('%filesize' => format_size($file->getSize()), '%quota' => format_size($user_limit))); } @@ -692,7 +692,7 @@ function file_file_download($uri, $field_type = 'file') { * Implements file_cron() */ function file_cron() { - $result = \Drupal::entityManager()->getStorageController('file')->retrieveTemporaryFiles(); + $result = \Drupal::entityManager()->getDefinition('file')->getStorage()->retrieveTemporaryFiles(); foreach ($result as $row) { if ($file = file_load($row->fid)) { $references = \Drupal::service('file.usage')->listUsage($file); diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php index 2b750b0..b8bae58 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php @@ -62,7 +62,7 @@ public function update() { // Decrement file usage by 1 for files that were removed from the field. $removed_fids = array_filter(array_diff($original_fids, $fids)); - $removed_files = \Drupal::entityManager()->getStorageController('file')->loadMultiple($removed_fids); + $removed_files = \Drupal::entityManager()->getDefinition('file')->getStorage()->loadMultiple($removed_fids); foreach ($removed_files as $file) { \Drupal::service('file.usage')->delete($file, 'file', $entity->entityType(), $entity->id()); } @@ -120,7 +120,7 @@ protected function targetEntities() { // Prevent NULLs as target IDs. $ids = array_filter($ids); - return $ids ? \Drupal::entityManager()->getStorageController('file')->loadMultiple($ids) : array(); + return $ids ? \Drupal::entityManager()->getDefinition('file')->getStorage()->loadMultiple($ids) : array(); } } diff --git a/core/modules/file/lib/Drupal/file/Plugin/views/argument/Fid.php b/core/modules/file/lib/Drupal/file/Plugin/views/argument/Fid.php index 96fa5ab..52882b0 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/views/argument/Fid.php +++ b/core/modules/file/lib/Drupal/file/Plugin/views/argument/Fid.php @@ -77,7 +77,7 @@ public function titleQuery() { $fids = $this->entityQuery->get('file') ->condition('fid', $this->value) ->execute(); - $controller = $this->entityManager->getStorageController('file'); + $controller = $this->entityManager->getDefinition('file')->getStorage(); $files = $controller->loadMultiple($fids); $titles = array(); foreach ($files as $file) { diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php index 7a8f3c5..9b58db5 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php @@ -209,7 +209,7 @@ function assertFileExists($file, $message = NULL) { * Asserts that a file exists in the database. */ function assertFileEntryExists($file, $message = NULL) { - $this->container->get('entity.manager')->getStorageController('file')->resetCache(); + \Drupal::entityManager()->getDefinition('file')->getStorage()->resetCache(); $db_file = file_load($file->id()); $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri())); $this->assertEqual($db_file->getFileUri(), $file->getFileUri(), $message); @@ -227,7 +227,7 @@ function assertFileNotExists($file, $message = NULL) { * Asserts that a file does not exist in the database. */ function assertFileEntryNotExists($file, $message) { - $this->container->get('entity.manager')->getStorageController('file')->resetCache(); + \Drupal::entityManager()->getDefinition('file')->getStorage()->resetCache(); $message = isset($message) ? $message : format_string('File %file exists in database at the correct path.', array('%file' => $file->getFileUri())); $this->assertFalse(file_load($file->id()), $message); } diff --git a/core/modules/file/lib/Drupal/file/Tests/SpaceUsedTest.php b/core/modules/file/lib/Drupal/file/Tests/SpaceUsedTest.php index 4925cbf..827076f 100644 --- a/core/modules/file/lib/Drupal/file/Tests/SpaceUsedTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/SpaceUsedTest.php @@ -43,7 +43,7 @@ function setUp() { * Test different users with the default status. */ function testFileSpaceUsed() { - $file = $this->container->get('entity.manager')->getStorageController('file'); + $file = \Drupal::entityManager()->getDefinition('file')->getStorage(); // Test different users with default status. $this->assertEqual($file->spaceUsed(2), 70); $this->assertEqual($file->spaceUsed(3), 300); diff --git a/core/modules/filter/filter.module b/core/modules/filter/filter.module index 4962044..f9654c6 100644 --- a/core/modules/filter/filter.module +++ b/core/modules/filter/filter.module @@ -198,7 +198,7 @@ function filter_formats(AccountInterface $account = NULL) { $formats['all'] = $cache->data; } else { - $formats['all'] = \Drupal::entityManager()->getStorageController('filter_format')->loadByProperties(array('status' => TRUE)); + $formats['all'] = \Drupal::entityManager()->getDefinition('filter_format')->getStorage()->loadByProperties(array('status' => TRUE)); uasort($formats['all'], 'Drupal\Core\Config\Entity\ConfigEntityBase::sort'); \Drupal::cache()->set("filter_formats:{$language_interface->id}", $formats['all'], CacheBackendInterface::CACHE_PERMANENT, array('filter_formats' => TRUE)); } diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php index e01e26b..f55dd6e 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatListController.php @@ -39,15 +39,11 @@ class FilterFormatListController extends DraggableListController implements Enti * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * 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, ConfigFactory $config_factory) { + parent::__construct($entity_info); $this->configFactory = $config_factory; } @@ -58,8 +54,6 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr 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('config.factory') ); } diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 9b405b2..c86eee9 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -148,8 +148,9 @@ function forum_menu_local_tasks(&$data, $route_name) { $links = array(); // Loop through all bundles for forum taxonomy vocabulary field. $field = Field::fieldInfo()->getField('node', 'taxonomy_forums'); + $node_access = \Drupal::entityManager()->getDefinition('node')->getAccess(); foreach ($field->getBundles() as $type) { - if (\Drupal::entityManager()->getAccessController('node')->createAccess($type)) { + if ($node_access->createAccess($type)) { $links[$type] = array( '#theme' => 'menu_local_action', '#link' => array( diff --git a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php index 2372e71..aa95d91 100644 --- a/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php +++ b/core/modules/forum/lib/Drupal/forum/Controller/ForumController.php @@ -97,8 +97,8 @@ public static function create(ContainerInterface $container) { return new static( $container->get('config.factory')->get('forum.settings'), $container->get('forum_manager'), - $container->get('entity.manager')->getStorageController('taxonomy_vocabulary'), - $container->get('entity.manager')->getStorageController('taxonomy_term'), + $container->get('entity.manager')->getDefinition('taxonomy_vocabulary')->getStorage(), + $container->get('entity.manager')->getDefinition('taxonomy_term')->getStorage(), $container->get('entity.manager'), $container->get('string_translation') ); diff --git a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php index 0605c0a..f5afc16 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php +++ b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php @@ -76,7 +76,7 @@ public function buildEntity(array $form, array &$form_state) { */ public function save(array $form, array &$form_state) { $term = $this->entity; - $term_storage = $this->entityManager->getStorageController('taxonomy_term'); + $term_storage = $this->entityManager->getDefinition('taxonomy_term')->getStorage(); $status = $term_storage->save($term); switch ($status) { diff --git a/core/modules/forum/lib/Drupal/forum/Form/Overview.php b/core/modules/forum/lib/Drupal/forum/Form/Overview.php index 560d535..1d95ed5 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/Overview.php +++ b/core/modules/forum/lib/Drupal/forum/Form/Overview.php @@ -62,7 +62,7 @@ public function getFormId() { public function buildForm(array $form, array &$form_state) { $forum_config = $this->config('forum.settings'); $vid = $forum_config->get('vocabulary'); - $vocabulary = $this->entityManager->getStorageController('taxonomy_vocabulary')->load($vid); + $vocabulary = $this->entityManager->getDefinition('taxonomy_vocabulary')->getStorage()->load($vid); if (!$vocabulary) { throw new NotFoundHttpException(); } diff --git a/core/modules/forum/lib/Drupal/forum/ForumBreadcrumbBuilder.php b/core/modules/forum/lib/Drupal/forum/ForumBreadcrumbBuilder.php index 6128aa8..544154a 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumBreadcrumbBuilder.php +++ b/core/modules/forum/lib/Drupal/forum/ForumBreadcrumbBuilder.php @@ -81,7 +81,7 @@ public function build(array $attributes) { * Builds the breadcrumb for a forum post page. */ protected function forumPostBreadcrumb($node) { - $vocabulary = $this->entityManager->getStorageController('taxonomy_vocabulary')->load($this->config->get('vocabulary')); + $vocabulary = $this->entityManager->getDefinition('taxonomy_vocabulary')->getStorage()->load($this->config->get('vocabulary')); $breadcrumb[] = $this->l($this->t('Home'), ''); $breadcrumb[] = l($vocabulary->label(), 'forum'); @@ -98,7 +98,7 @@ protected function forumPostBreadcrumb($node) { * Builds the breadcrumb for a forum term page. */ protected function forumTermBreadcrumb($term) { - $vocabulary = $this->entityManager->getStorageController('taxonomy_vocabulary')->load($this->config->get('vocabulary')); + $vocabulary = $this->entityManager->getDefinition('taxonomy_vocabulary')->getStorage()->load($this->config->get('vocabulary')); $breadcrumb[] = $this->l($this->t('Home'), ''); if ($term->tid) { diff --git a/core/modules/forum/lib/Drupal/forum/ForumManager.php b/core/modules/forum/lib/Drupal/forum/ForumManager.php index 5c530c7..0cb0cb9 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumManager.php +++ b/core/modules/forum/lib/Drupal/forum/ForumManager.php @@ -181,7 +181,7 @@ public function getTopics($tid) { $nids[] = $record->nid; } if ($nids) { - $nodes = $this->entityManager->getStorageController('node')->loadMultiple($nids); + $nodes = $this->entityManager->getDefinition('node')->getStorage()->loadMultiple($nids); $query = $this->connection->select('node_field_data', 'n') ->extend('Drupal\Core\Database\Query\TableSortExtender'); @@ -453,7 +453,7 @@ public function getIndex() { } $vid = $this->configFactory->get('forum.settings')->get('vocabulary'); - $index = $this->entityManager->getStorageController('taxonomy_term')->create(array( + $index = $this->entityManager->getDefinition('taxonomy_term')->getStorage()->create(array( 'tid' => 0, 'container' => 1, 'parents' => array(), diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index 6b1fa37..cf91e6f 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -398,7 +398,7 @@ function createForum($type, $parent = 0) { $parent_tid = db_query("SELECT t.parent FROM {taxonomy_term_hierarchy} t WHERE t.tid = :tid", array(':tid' => $tid))->fetchField(); $this->assertTrue($parent == $parent_tid, 'The ' . $type . ' is linked to its container'); - $forum = $this->container->get('entity.manager')->getStorageController('taxonomy_term')->load($tid); + $forum = \Drupal::entityManager()->getDefinition('taxonomy_term')->getStorage()->load($tid); $this->assertEqual(($type == 'forum container'), (bool) $forum->forum_container->value); return $term; } diff --git a/core/modules/forum/lib/Drupal/forum/Tests/Views/ForumIntegrationTest.php b/core/modules/forum/lib/Drupal/forum/Tests/Views/ForumIntegrationTest.php index b7fe19d..f5e34fb 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/Views/ForumIntegrationTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/Views/ForumIntegrationTest.php @@ -50,10 +50,10 @@ protected function setUp() { public function testForumIntegration() { // Create a forum. $entity_manager = $this->container->get('entity.manager'); - $term = $entity_manager->getStorageController('taxonomy_term')->create(array('vid' => 'forums')); + $term = $entity_manager->getDefinition('taxonomy_term')->getStorage()->create(array('vid' => 'forums')); $term->save(); - $comment_storage_controller = $entity_manager->getStorageController('comment'); + $comment_storage_controller = $entity_manager->getDefinition('comment')->getStorage(); // Create some nodes which are part of this forum with some comments. $nodes = array(); diff --git a/core/modules/forum/tests/Drupal/forum/Tests/ForumManagerTest.php b/core/modules/forum/tests/Drupal/forum/Tests/ForumManagerTest.php index 8d3be5f..3397b4c 100644 --- a/core/modules/forum/tests/Drupal/forum/Tests/ForumManagerTest.php +++ b/core/modules/forum/tests/Drupal/forum/Tests/ForumManagerTest.php @@ -50,10 +50,16 @@ public function testGetIndex() { ->method('get') ->will($this->returnValue('forums')); - $entity_manager->expects($this->once()) - ->method('getStorageController') + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->once()) + ->method('getStorage') ->will($this->returnValue($storage_controller)); + $entity_manager->expects($this->once()) + ->method('getDefinition') + ->with($this->equalTo('taxonomy_term')) + ->will($this->returnValue($entity_type)); + // This is sufficient for testing purposes. $term = new \stdClass(); diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php index c00b009..e38647e 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php @@ -7,7 +7,6 @@ namespace Drupal\image\Form; -use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\image\ConfigurableImageEffectInterface; use Drupal\image\ImageEffectManager; use Drupal\Component\Utility\String; @@ -28,13 +27,10 @@ class ImageStyleEditForm extends ImageStyleFormBase { /** * Constructs an ImageStyleEditForm object. * - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $image_style_storage - * The storage controller. * @param \Drupal\image\ImageEffectManager $image_effect_manager * The image effect manager service. */ - public function __construct(EntityStorageControllerInterface $image_style_storage, ImageEffectManager $image_effect_manager) { - parent::__construct($image_style_storage); + public function __construct(ImageEffectManager $image_effect_manager) { $this->imageEffectManager = $image_effect_manager; } @@ -43,7 +39,6 @@ public function __construct(EntityStorageControllerInterface $image_style_storag */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('image_style'), $container->get('plugin.manager.image.effect') ); } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php index 3ec0b2d..c119561 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php @@ -8,8 +8,6 @@ namespace Drupal\image\Form; use Drupal\Core\Entity\EntityFormController; -use Drupal\Core\Entity\EntityStorageControllerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Base form controller for image style add and edit forms. @@ -17,32 +15,6 @@ abstract class ImageStyleFormBase extends EntityFormController { /** - * The image style entity storage controller. - * - * @var \Drupal\Core\Entity\EntityStorageControllerInterface - */ - protected $imageStyleStorage; - - /** - * Constructs a base class for image style add and edit forms. - * - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $image_style_storage - * The image style entity storage controller. - */ - public function __construct(EntityStorageControllerInterface $image_style_storage) { - $this->imageStyleStorage = $image_style_storage; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.manager')->getStorageController('image_style') - ); - } - - /** * {@inheritdoc} */ public function form(array $form, array &$form_state) { @@ -56,7 +28,7 @@ public function form(array $form, array &$form_state) { $form['name'] = array( '#type' => 'machine_name', '#machine_name' => array( - 'exists' => array($this->imageStyleStorage, 'load'), + 'exists' => array($this->getStorage(), 'load'), ), '#default_value' => $this->entity->id(), '#required' => TRUE, diff --git a/core/modules/image/lib/Drupal/image/ImageStyleListController.php b/core/modules/image/lib/Drupal/image/ImageStyleListController.php index bf5618b..6e32c97 100644 --- a/core/modules/image/lib/Drupal/image/ImageStyleListController.php +++ b/core/modules/image/lib/Drupal/image/ImageStyleListController.php @@ -10,11 +10,8 @@ use Drupal\Core\Config\Entity\ConfigEntityListController; use Drupal\Core\Entity\EntityControllerInterface; 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; /** @@ -34,15 +31,11 @@ class ImageStyleListController extends ConfigEntityListController implements Ent * * @param EntityTypeInterface $entity_info * 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, UrlGeneratorInterface $url_generator) { + parent::__construct($entity_info); $this->urlGenerator = $url_generator; } @@ -52,10 +45,7 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr 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('url_generator'), - $container->get('string_translation') + $container->get('url_generator') ); } diff --git a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php index e71beac..9d21ec3 100644 --- a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php +++ b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php @@ -512,7 +512,7 @@ function testLinkSeparateFormatter() { */ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) { if ($reset) { - $this->container->get('entity.manager')->getStorageController('entity_test')->resetCache(array($id)); + \Drupal::entityManager()->getDefinition('entity_test')->getStorage()->resetCache(array($id)); } $entity = entity_load('entity_test', $id); $display = entity_get_display($entity->entityType(), $entity->bundle(), $view_mode); diff --git a/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php index 1be24be..d482085 100644 --- a/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php +++ b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php @@ -33,7 +33,7 @@ class LocaleAdminPathConfigEntityConverter extends EntityConverter { */ public function convert($value, $definition, $name, array $defaults, Request $request) { $entity_type = substr($definition['type'], strlen('entity:')); - if ($storage = $this->entityManager->getStorageController($entity_type)) { + if ($storage = $this->entityManager->getDefinition($entity_type)->getStorage()) { // Enter the override-free context, so we can ensure no overrides are // applied. config_context_enter('config.context.free'); diff --git a/core/modules/menu/lib/Drupal/menu/Controller/MenuController.php b/core/modules/menu/lib/Drupal/menu/Controller/MenuController.php index bcf65dc..9eb461d 100644 --- a/core/modules/menu/lib/Drupal/menu/Controller/MenuController.php +++ b/core/modules/menu/lib/Drupal/menu/Controller/MenuController.php @@ -53,7 +53,7 @@ public function __construct(MenuLinkStorageControllerInterface $menu_link_storag */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('menu_link'), + $container->get('entity.manager')->getDefinition('menu_link')->getStorage(), $container->get('entity.manager') ); } diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php index 35d074d..1c76f66 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php @@ -18,13 +18,6 @@ class MenuDeleteForm extends EntityConfirmFormBase { /** - * The menu link storage controller. - * - * @var \Drupal\Core\Entity\EntityStorageControllerInterface - */ - protected $storageController; - - /** * The database connection. * * @var \Drupal\Core\Database\Connection @@ -34,13 +27,10 @@ class MenuDeleteForm extends EntityConfirmFormBase { /** * Constructs a new MenuDeleteForm. * - * @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage_controller - * The menu link storage controller. * @param \Drupal\Core\Database\Connection $connection * The database connection. */ - public function __construct(EntityStorageControllerInterface $storage_controller, Connection $connection) { - $this->storageController = $storage_controller; + public function __construct(Connection $connection) { $this->connection = $connection; } @@ -49,7 +39,6 @@ public function __construct(EntityStorageControllerInterface $storage_controller */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('menu_link'), $container->get('database') ); } @@ -78,7 +67,7 @@ public function getCancelRoute() { */ public function getDescription() { $caption = ''; - $num_links = $this->storageController->countMenuLinks($this->entity->id()); + $num_links = $this->getStorage()->countMenuLinks($this->entity->id()); if ($num_links) { $caption .= '

' . format_plural($num_links, 'Warning: There is currently 1 menu link in %title. It will be deleted (system-defined items will be reset).', 'Warning: There are currently @count menu links in %title. They will be deleted (system-defined links will be reset).', array('%title' => $this->entity->label())) . '

'; } @@ -107,13 +96,13 @@ public function submit(array $form, array &$form_state) { // Reset all the menu links defined by the system via hook_menu(). // @todo Convert this to an EFQ once we figure out 'ORDER BY m.number_parts'. $result = $this->connection->query("SELECT mlid FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.menu_name = :menu AND ml.module = 'system' ORDER BY m.number_parts ASC", array(':menu' => $this->entity->id()), array('fetch' => \PDO::FETCH_ASSOC))->fetchCol(); - $menu_links = $this->storageController->loadMultiple($result); + $menu_links = $this->getStorage()->loadMultiple($result); foreach ($menu_links as $link) { $link->reset(); } // Delete all links to the overview page for this menu. - $menu_links = $this->storageController->loadByProperties(array('link_path' => 'admin/structure/menu/manage/' . $this->entity->id())); + $menu_links = $this->getStorage()->loadByProperties(array('link_path' => 'admin/structure/menu/manage/' . $this->entity->id())); menu_link_delete_multiple(array_keys($menu_links)); // Delete the custom menu and all its menu links. diff --git a/core/modules/menu/lib/Drupal/menu/MenuFormController.php b/core/modules/menu/lib/Drupal/menu/MenuFormController.php index 5e369d5..3e93e32 100644 --- a/core/modules/menu/lib/Drupal/menu/MenuFormController.php +++ b/core/modules/menu/lib/Drupal/menu/MenuFormController.php @@ -11,7 +11,6 @@ use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Language\Language; -use Drupal\menu_link\MenuLinkStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -27,13 +26,6 @@ class MenuFormController extends EntityFormController { protected $entityQueryFactory; /** - * The menu link storage controller. - * - * @var \Drupal\menu_link\MenuLinkStorageControllerInterface - */ - protected $menuLinkStorage; - - /** * The overview tree form. * * @var array @@ -45,12 +37,9 @@ class MenuFormController extends EntityFormController { * * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query_factory * The factory for entity queries. - * @param \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage - * The menu link storage controller. */ - public function __construct(QueryFactory $entity_query_factory, MenuLinkStorageControllerInterface $menu_link_storage) { + public function __construct(QueryFactory $entity_query_factory) { $this->entityQueryFactory = $entity_query_factory; - $this->menuLinkStorage = $menu_link_storage; } /** @@ -58,8 +47,7 @@ public function __construct(QueryFactory $entity_query_factory, MenuLinkStorageC */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.query'), - $container->get('entity.manager')->getStorageController('menu_link') + $container->get('entity.query') ); } @@ -269,7 +257,7 @@ protected function buildOverviewForm(array &$form, array &$form_state) { $result = $query->execute(); if (!empty($result)) { - $links = $this->menuLinkStorage->loadMultiple($result); + $links = $this->getStorage()->loadMultiple($result); } $delta = max(count($links), 50); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php index 638f47f..7e25333 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php @@ -399,7 +399,7 @@ public static function buildFromRouterItem(array $item) { 'options' => empty($item['description']) ? array() : array('attributes' => array('title' => $item['description'])), ); return \Drupal::entityManager() - ->getStorageController('menu_link')->create($item); + ->getDefinition('menu_link')->getStorage()->create($item); } /** diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php index bc2c71d..c60ab94 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -11,7 +11,6 @@ use Drupal\Core\Language\Language; use Drupal\Core\Path\AliasManagerInterface; use Drupal\Core\Routing\UrlGenerator; -use Drupal\menu_link\MenuLinkStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -20,13 +19,6 @@ class MenuLinkFormController extends EntityFormController { /** - * The menu link storage controller. - * - * @var \Drupal\menu_link\MenuLinkStorageControllerInterface - */ - protected $menuLinkStorageController; - - /** * The path alias manager. * * @var \Drupal\Core\Path\AliasManagerInterface @@ -43,15 +35,12 @@ class MenuLinkFormController extends EntityFormController { /** * Constructs a new MenuLinkFormController object. * - * @param \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage_controller - * The menu link storage. * @param \Drupal\Core\Path\AliasManagerInterface $path_alias_manager * The path alias manager. * @param \Drupal\Core\Routing\UrlGenerator $url_generator * The URL generator. */ - public function __construct(MenuLinkStorageControllerInterface $menu_link_storage_controller, AliasManagerInterface $path_alias_manager, UrlGenerator $url_generator) { - $this->menuLinkStorageController = $menu_link_storage_controller; + public function __construct(AliasManagerInterface $path_alias_manager, UrlGenerator $url_generator) { $this->pathAliasManager = $path_alias_manager; $this->urlGenerator = $url_generator; } @@ -61,7 +50,6 @@ public function __construct(MenuLinkStorageControllerInterface $menu_link_storag */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('menu_link'), $container->get('path.alias_manager.cached'), $container->get('url_generator') ); @@ -152,7 +140,7 @@ public function form(array $form, array &$form_state) { ); // Get number of items in menu so the weight selector is sized appropriately. - $delta = $this->menuLinkStorageController->countMenuLinks($menu_link->menu_name); + $delta = $this->getStorage()->countMenuLinks($menu_link->menu_name); $form['weight'] = array( '#type' => 'weight', '#title' => t('Weight'), diff --git a/core/modules/menu_link/menu_link.module b/core/modules/menu_link/menu_link.module index 5a393de..9ed24f9 100644 --- a/core/modules/menu_link/menu_link.module +++ b/core/modules/menu_link/menu_link.module @@ -99,7 +99,7 @@ function menu_link_delete_multiple(array $mlids, $force = FALSE, $prevent_repare } $controller = \Drupal::entityManager() - ->getStorageController('menu_link'); + ->getDefinition('menu_link')->getStorage(); if (!$force) { $entity_query = \Drupal::entityQuery('menu_link'); $group = $entity_query->orConditionGroup() @@ -154,7 +154,7 @@ function menu_link_save(MenuLink $menu_link) { */ function menu_link_maintain($module, $op, $link_path, $link_title = NULL) { $menu_link_controller = \Drupal::entityManager() - ->getStorageController('menu_link'); + ->getDefinition('menu_link')->getStorage(); switch ($op) { case 'insert': $menu_link = entity_create('menu_link', array( diff --git a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php index 97e4121..4881b98 100644 --- a/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php +++ b/core/modules/migrate/lib/Drupal/migrate/Plugin/migrate/destination/Entity.php @@ -52,7 +52,7 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('entity.manager')->getStorageController($configuration['entity_type']) + $container->get('entity.manager')->getDefinition($configuration['entity_type'])->getStorage() ); } diff --git a/core/modules/node/lib/Drupal/node/Access/NodeAddAccessCheck.php b/core/modules/node/lib/Drupal/node/Access/NodeAddAccessCheck.php index 8d72223..7d85340 100644 --- a/core/modules/node/lib/Drupal/node/Access/NodeAddAccessCheck.php +++ b/core/modules/node/lib/Drupal/node/Access/NodeAddAccessCheck.php @@ -39,7 +39,7 @@ public function __construct(EntityManagerInterface $entity_manager) { * {@inheritdoc} */ public function access(Route $route, Request $request, AccountInterface $account) { - $access_controller = $this->entityManager->getAccessController('node'); + $access_controller = $this->entityManager->getDefinition('node')->getAccess(); // If a node type is set on the request, just check that. if ($request->attributes->has('node_type')) { return $access_controller->createAccess($request->attributes->get('node_type')->type, $account) ? static::ALLOW : static::DENY; diff --git a/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php b/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php index 353a8fb..e1d5bd1 100644 --- a/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php +++ b/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php @@ -57,8 +57,9 @@ class NodeRevisionAccessCheck implements AccessInterface { * The database connection. */ public function __construct(EntityManagerInterface $entity_manager, Connection $connection) { - $this->nodeStorage = $entity_manager->getStorageController('node'); - $this->nodeAccess = $entity_manager->getAccessController('node'); + $entity_type = $entity_manager->getDefinition('node'); + $this->nodeStorage = $entity_type->getStorage(); + $this->nodeAccess = $entity_type->getAccess(); $this->connection = $connection; } diff --git a/core/modules/node/lib/Drupal/node/Controller/NodeController.php b/core/modules/node/lib/Drupal/node/Controller/NodeController.php index a60696c..a3ad369 100644 --- a/core/modules/node/lib/Drupal/node/Controller/NodeController.php +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php @@ -34,8 +34,8 @@ public function addPage() { $content = array(); // Only use node types the user has access to. - foreach ($this->entityManager()->getStorageController('node_type')->loadMultiple() as $type) { - if ($this->entityManager()->getAccessController('node')->createAccess($type->type)) { + foreach ($this->entityManager()->getDefinition('node_type')->getStorage()->loadMultiple() as $type) { + if ($this->entityManager()->getDefinition('node')->getAccess()->createAccess($type->type)) { $content[$type->type] = $type; } } @@ -65,7 +65,7 @@ public function add(NodeTypeInterface $node_type) { $account = $this->currentUser(); $langcode = $this->moduleHandler()->invoke('language', 'get_default_langcode', array('node', $node_type->type)); - $node = $this->entityManager()->getStorageController('node')->create(array( + $node = $this->entityManager()->getDefinition('node')->getStorage()->create(array( 'uid' => $account->id(), 'name' => $account->getUsername() ?: '', 'type' => $node_type->type, @@ -87,7 +87,7 @@ public function add(NodeTypeInterface $node_type) { * An array suitable for drupal_render(). */ public function revisionShow($node_revision) { - $node = $this->entityManager()->getStorageController('node')->loadRevision($node_revision); + $node = $this->entityManager()->getDefinition('node')->getStorage()->loadRevision($node_revision); $page = $this->buildPage($node); unset($page['nodes'][$node->id()]['#cache']); @@ -104,7 +104,7 @@ public function revisionShow($node_revision) { * The page title. */ public function revisionPageTitle($node_revision) { - $node = $this->entityManager()->getStorageController('node')->loadRevision($node_revision); + $node = $this->entityManager()->getDefinition('node')->getStorage()->loadRevision($node_revision); return $this->t('Revision of %title from %date', array('%title' => $node->label(), '%date' => format_date($node->getRevisionCreationTime()))); } @@ -175,7 +175,7 @@ public function pageTitle(NodeInterface $node) { * An array suitable for drupal_render(). */ protected function buildPage(NodeInterface $node) { - return array('nodes' => $this->entityManager()->getViewBuilder('node')->view($node)); + return array('nodes' => $this->entityManager()->getDefinition('node')->getViewBuilder()->view($node)); } /** diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index fee4c18..0f1f02a 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -136,7 +136,7 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ // default revision. There's no need to delete existing records if the node // is new. if ($this->isDefaultRevision()) { - \Drupal::entityManager()->getAccessController('node')->writeGrants($this, $update); + $this->entityInfo()->getAccess()->writeGrants($this, $update); } // Reindex the node when it is updated. The node is automatically indexed @@ -183,9 +183,7 @@ public function access($operation = 'view', AccountInterface $account = NULL) { return parent::access($operation, $account); } - return \Drupal::entityManager() - ->getAccessController($this->entityType) - ->access($this, $operation, $this->prepareLangcode(), $account); + return $this->entityInfo()->getAccess()->access($this, $operation, $this->prepareLangcode(), $account); } /** diff --git a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php index 09ad79c..d547675 100644 --- a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php +++ b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php @@ -52,7 +52,7 @@ class DeleteMultiple extends ConfirmFormBase implements ContainerInjectionInterf */ public function __construct(TempStoreFactory $temp_store_factory, EntityManagerInterface $manager) { $this->tempStoreFactory = $temp_store_factory; - $this->storageController = $manager->getStorageController('node'); + $this->storageController = $manager->getDefinition('node')->getStorage(); } /** diff --git a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php index 644b069..7949d27 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php @@ -87,7 +87,7 @@ public function getConfirmText() { public function submit(array $form, array &$form_state) { $this->entity->delete(); watchdog('content', '@type: deleted %title.', array('@type' => $this->entity->bundle(), '%title' => $this->entity->label())); - $node_type_storage = $this->entityManager->getStorageController('node_type'); + $node_type_storage = $this->entityManager->getDefinition('node_type')->getStorage(); $node_type = $node_type_storage->load($this->entity->bundle())->label(); drupal_set_message(t('@type %title has been deleted.', array('@type' => $node_type, '%title' => $this->entity->label()))); Cache::invalidateTags(array('content' => TRUE)); diff --git a/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php b/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php index 99edd0e..483d895 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php @@ -69,8 +69,8 @@ public function __construct(EntityStorageControllerInterface $node_storage, Enti public static function create(ContainerInterface $container) { $entity_manager = $container->get('entity.manager'); return new static( - $entity_manager->getStorageController('node'), - $entity_manager->getStorageController('node_type'), + $entity_manager->getDefinition('node')->getStorage(), + $entity_manager->getDefinition('node_type')->getStorage(), $container->get('database') ); } diff --git a/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php b/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php index 12cb9e3..ae5f533 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php @@ -47,7 +47,7 @@ public function __construct(EntityStorageControllerInterface $node_storage) { */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('node') + $container->get('entity.manager')->getDefinition('node')->getStorage() ); } diff --git a/core/modules/node/lib/Drupal/node/NodeListController.php b/core/modules/node/lib/Drupal/node/NodeListController.php index 8d488ca..a433551 100644 --- a/core/modules/node/lib/Drupal/node/NodeListController.php +++ b/core/modules/node/lib/Drupal/node/NodeListController.php @@ -11,7 +11,6 @@ use Drupal\Core\Datetime\Date; use Drupal\Core\Entity\EntityInterface; 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; @@ -35,15 +34,11 @@ class NodeListController extends EntityListController { * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * 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, Date $date_service) { + parent::__construct($entity_info); $this->dateService = $date_service; } @@ -54,8 +49,6 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr 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('date') ); } diff --git a/core/modules/node/lib/Drupal/node/NodeTypeListController.php b/core/modules/node/lib/Drupal/node/NodeTypeListController.php index 813f6ca..98ab6af 100644 --- a/core/modules/node/lib/Drupal/node/NodeTypeListController.php +++ b/core/modules/node/lib/Drupal/node/NodeTypeListController.php @@ -10,8 +10,6 @@ use Drupal\Core\Entity\EntityControllerInterface; 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; @@ -34,15 +32,11 @@ class NodeTypeListController extends ConfigEntityListController implements Entit * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * 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, UrlGeneratorInterface $url_generator) { + parent::__construct($entity_info); $this->urlGenerator = $url_generator; } @@ -52,8 +46,6 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr 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('url_generator') ); } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php index 573447d..b5f7494 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Search/NodeSearch.php @@ -43,11 +43,18 @@ class NodeSearch extends SearchPluginBase implements AccessibleInterface, Search protected $database; /** - * An entity manager object. + * The node entity type. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeInterface */ - protected $entityManager; + protected $nodeEntityType; + + /** + * The node type entity type. + * + * @var \Drupal\Core\Entity\EntityTypeInterface + */ + protected $nodeTypeEntityType; /** * A module manager object. @@ -138,7 +145,8 @@ static public function create(ContainerInterface $container, array $configuratio */ public function __construct(array $configuration, $plugin_id, array $plugin_definition, Connection $database, EntityManagerInterface $entity_manager, ModuleHandlerInterface $module_handler, Config $search_settings, StateInterface $state, AccountInterface $account = NULL) { $this->database = $database; - $this->entityManager = $entity_manager; + $this->nodeEntityType = $entity_manager->getDefinition('node'); + $this->nodeTypeEntityType = $entity_manager->getDefinition('node_type'); $this->moduleHandler = $module_handler; $this->searchSettings = $search_settings; $this->state = $state; @@ -223,8 +231,8 @@ public function execute() { ->limit(10) ->execute(); - $node_storage = $this->entityManager->getStorageController('node'); - $node_render = $this->entityManager->getViewBuilder('node'); + $node_storage = $this->nodeEntityType->getStorage(); + $node_render = $this->nodeEntityType->getViewBuilder(); foreach ($find as $item) { // Render the node. @@ -246,7 +254,7 @@ public function execute() { ); $results[] = array( 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), - 'type' => check_plain($this->entityManager->getStorageController('node_type')->load($node->bundle())->label()), + 'type' => check_plain($this->nodeTypeEntityType->getStorage()->load($node->bundle())->label()), 'title' => $node->label(), 'user' => drupal_render($username), 'date' => $node->getChangedTime(), @@ -298,7 +306,7 @@ public function updateIndex() { // The indexing throttle should be aware of the number of language variants // of a node. $counter = 0; - $node_storage = $this->entityManager->getStorageController('node'); + $node_storage = $this->nodeEntityType->getStorage(); foreach ($node_storage->loadMultiple($nids) as $node) { // Determine when the maximum number of indexable items is reached. $counter += count($node->getTranslationLanguages()); @@ -321,7 +329,7 @@ protected function indexNode(EntityInterface $node) { $this->state->set('node.cron_last', $node->getChangedTime()); $languages = $node->getTranslationLanguages(); - $node_render = $this->entityManager->getViewBuilder('node'); + $node_render = $this->nodeEntityType->getViewBuilder(); foreach ($languages as $language) { $node = $node->getTranslation($language->id); @@ -404,7 +412,6 @@ public function searchFormAlter(array &$form, array &$form_state) { ); // Add node types. - $node_types = $this->entityManager->getStorageController('node_type')->loadMultiple(); $types = array_map('check_plain', node_type_get_names()); $form['advanced']['types-fieldset'] = array( '#type' => 'fieldset', diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php index 9ea6731..1328d96 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php @@ -155,7 +155,7 @@ function testNodeAccessPrivate() { $this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user, 'hr'); // Reset the node access cache and turn on our test node access code. - entity_access_controller('node')->resetCache(); + \Drupal::entityManager()->getDefinition('node')->getAccess()->resetCache(); \Drupal::state()->set('node_access_test_secret_catalan', 1); // Tests that access is not granted if requested with no language. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTestBase.php b/core/modules/node/lib/Drupal/node/Tests/NodeTestBase.php index dcb0518..9c8aad0 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTestBase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTestBase.php @@ -43,7 +43,7 @@ function setUp() { ))); $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); } - $this->accessController = \Drupal::entityManager()->getAccessController('node'); + $this->accessController = \Drupal::entityManager()->getDefinition('node')->getAccess(); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php index c8d554c..85e6bf7 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php @@ -230,7 +230,7 @@ function testTranslationRendering() { $default_langcode = $this->langcodes[0]; $values[$default_langcode] = $this->getNewEntityValues($default_langcode); $this->entityId = $this->createEntity($values[$default_langcode], $default_langcode); - $node = \Drupal::entityManager()->getStorageController($this->entityType)->load($this->entityId); + $node = \Drupal::entityManager()->getDefinition($this->entityType)->getStorage()->load($this->entityId); $node->setPromoted(TRUE); // Create translations. diff --git a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php index 9ad3373..c0a2fb9 100644 --- a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php @@ -35,7 +35,7 @@ function testSummaryLength() { $web_user = $this->drupalCreateUser(array('access content', 'administer content types')); $this->loggedInUser = $web_user; - $controller = $this->container->get('entity.manager')->getViewBuilder('node'); + $controller = \Drupal::entityManager()->getDefinition('node')->getViewBuilder(); // Render the node as a teaser. $content = $controller->view($node, 'teaser'); $this->assertTrue(strlen($content['body'][0]['#markup']) < 600, 'Teaser is less than 600 characters long.'); diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/FrontpageTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/FrontpageTest.php index e94d171..911ec9b 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/FrontpageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/FrontpageTest.php @@ -40,7 +40,7 @@ public static function getInfo() { protected function setUp() { parent::setUp(); - $this->nodeStorageController = $this->container->get('entity.manager')->getStorageController('node'); + $this->nodeStorageController = \Drupal::entityManager()->getDefinition('node')->getStorage(); } /** diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 8c104dd..df895e4 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -17,7 +17,7 @@ function node_requirements($phase) { // Only show rebuild button if there are either 0, or 2 or more, rows // in the {node_access} table, or if there are modules that // implement hook_node_grants(). - $grant_count = \Drupal::entityManager()->getAccessController('node')->countGrants(); + $grant_count = \Drupal::entityManager()->getDefinition('node')->getAccess()->countGrants(); if ($grant_count != 1 || count(\Drupal::moduleHandler()->getImplementations('node_grants')) > 0) { $value = format_plural($grant_count, 'One permission in use', '@count permissions in use', array('@count' => $grant_count)); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 8becc7f..a26f6a8 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1675,7 +1675,7 @@ function node_access_view_all_nodes($account = NULL) { $access[$account->id()] = TRUE; } else { - $access[$account->id()] = \Drupal::entityManager()->getAccessController('node')->checkAllGrants($account); + $access[$account->id()] = \Drupal::entityManager()->getDefinition('node')->getAccess()->checkAllGrants($account); } return $access[$account->id()]; @@ -1799,7 +1799,7 @@ function node_access_needs_rebuild($rebuild = NULL) { * @see node_access_needs_rebuild() */ function node_access_rebuild($batch_mode = FALSE) { - $access_controller = \Drupal::entityManager()->getAccessController('node'); + $access_controller = \Drupal::entityManager()->getDefinition('node')->getAccess(); $access_controller->deleteGrants(); // Only recalculate if the site is using a node_access module. if (count(\Drupal::moduleHandler()->getImplementations('node_grants'))) { @@ -1873,7 +1873,7 @@ function _node_access_rebuild_batch_operation(&$context) { // To preserve database integrity, only write grants if the node // loads successfully. if (!empty($node)) { - \Drupal::entityManager()->getAccessController('node')->writeGrants($node); + \Drupal::entityManager()->getDefinition('node')->getAccess()->writeGrants($node); } $context['sandbox']['progress']++; $context['sandbox']['current_node'] = $nid; diff --git a/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php b/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php index aec235c..4a401a3 100644 --- a/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php +++ b/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php @@ -49,16 +49,21 @@ public function testConstructor() { ->will($this->returnValue('user')); $actions[] = $action; - $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $storage_controller = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface'); $storage_controller->expects($this->any()) ->method('loadMultiple') ->will($this->returnValue($actions)); - $entity_manager->expects($this->any()) - ->method('getStorageController') - ->with('action') + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->any()) + ->method('getStorage') ->will($this->returnValue($storage_controller)); + + $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); + $entity_manager->expects($this->any()) + ->method('getDefinition') + ->with($this->equalTo('action')) + ->will($this->returnValue($entity_type)); $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', array(), $entity_manager); $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form); diff --git a/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php b/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php index cdb70c5..42afe6a 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php +++ b/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php @@ -169,8 +169,9 @@ public function getExportProperties() { public function postSave(EntityStorageControllerInterface $storage_controller, $update = TRUE) { parent::postSave($storage_controller, $update); - if (\Drupal::entityManager()->hasController($this->targetEntityType, 'render')) { - \Drupal::entityManager()->getViewBuilder($this->targetEntityType)->resetCache(); + $entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); + if ($entity_type->hasController('view_builder')) { + $entity_type->getViewBuilder()->resetCache(); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.php b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.php index a7b0d42..c059a7b 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutController.php @@ -27,7 +27,7 @@ class ShortcutController extends ControllerBase { * The shortcut add form. */ public function addForm(ShortcutSetInterface $shortcut_set) { - $shortcut = $this->entityManager()->getStorageController('shortcut')->create(array('shortcut_set' => $shortcut_set->id())); + $shortcut = $this->entityManager()->getDefinition('shortcut')->getStorage()->create(array('shortcut_set' => $shortcut_set->id())); if ($this->moduleHandler()->moduleExists('language')) { $shortcut->langcode = language_get_default_langcode('shortcut', $shortcut_set->id()); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php index 2d90342..c3c6736 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Controller/ShortcutSetController.php @@ -36,7 +36,7 @@ public function addShortcutLinkInline(ShortcutSetInterface $shortcut_set, Reques $link = $request->query->get('link'); $name = $request->query->get('name'); if (shortcut_valid_link($link)) { - $shortcut = $this->entityManager()->getStorageController('shortcut')->create(array( + $shortcut = $this->entityManager()->getDefinition('shortcut')->getStorage()->create(array( 'title' => $name, 'shortcut_set' => $shortcut_set->id(), 'path' => $link, diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php b/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php index ef2c480..190a391 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Entity/ShortcutSet.php @@ -97,7 +97,7 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr ->condition('shortcut_set', $entity->id(), '=') ->execute(); - $controller = \Drupal::entityManager()->getStorageController('shortcut'); + $controller = \Drupal::entityManager()->getDefinition('shortcut')->getStorage(); $entities = $controller->loadMultiple($shortcut_ids); $controller->delete($entities); } @@ -120,7 +120,7 @@ public function resetLinkWeights() { * {@inheritdoc} */ public function getShortcuts() { - return \Drupal::entityManager()->getStorageController('shortcut')->loadByProperties(array('shortcut_set' => $this->id())); + return \Drupal::entityManager()->getDefinition('shortcut')->getStorage()->loadByProperties(array('shortcut_set' => $this->id())); } } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php index 12a789c..c77baff 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/SetCustomize.php @@ -17,32 +17,6 @@ class SetCustomize extends EntityFormController { /** - * The shortcut storage controller. - * - * @var \Drupal\Core\Entity\EntityStorageControllerInterface - */ - protected $storageController; - - /** - * Constructs a SetCustomize object. - * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. - */ - public function __construct(EntityManagerInterface $entity_manager) { - $this->storageController = $entity_manager->getStorageController('shortcut'); - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.manager') - ); - } - - /** * {@inheritdoc} */ public function form(array $form, array &$form_state) { @@ -66,7 +40,7 @@ public function form(array $form, array &$form_state) { ), ); - $shortcuts = $this->storageController->loadByProperties(array('shortcut_set' => $this->entity->id())); + $shortcuts = $this->getStorage()->loadByProperties(array('shortcut_set' => $this->entity->id())); foreach ($shortcuts as $shortcut) { $id = $shortcut->id(); $form['shortcuts']['links'][$id]['#attributes']['class'][] = 'draggable'; @@ -119,7 +93,7 @@ protected function actions(array $form, array &$form_state) { * {@inheritdoc} */ public function save(array $form, array &$form_state) { - $shortcuts = $this->storageController->loadByProperties(array('shortcut_set' => $this->entity->id())); + $shortcuts = $this->getStorage()->loadByProperties(array('shortcut_set' => $this->entity->id())); foreach ($shortcuts as $shortcut) { $shortcut->weight->value = $form_state['values']['shortcuts']['links'][$shortcut->id()]['weight']; $shortcut->save(); diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php index 0b97ded..39e178b 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php @@ -8,9 +8,6 @@ namespace Drupal\shortcut\Form; use Drupal\Core\Entity\EntityConfirmFormBase; -use Drupal\shortcut\ShortcutSetStorageControllerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Drupal\Core\Database\Connection; /** * Builds the shortcut set deletion form. @@ -18,38 +15,6 @@ class ShortcutSetDeleteForm extends EntityConfirmFormBase { /** - * The database connection. - * - * @var \Drupal\Core\Database\Connection - */ - protected $database; - - /** - * The shortcut storage controller. - * - * @var \Drupal\shortcut\ShortcutSetStorageControllerInterface - */ - protected $storageController; - - /** - * Constructs a ShortcutSetDeleteForm object. - */ - public function __construct(Connection $database, ShortcutSetStorageControllerInterface $storage_controller) { - $this->database = $database; - $this->storageController = $storage_controller; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('database'), - $container->get('entity.manager')->getStorageController('shortcut_set') - ); - } - - /** * {@inheritdoc} */ public function getQuestion() { @@ -81,7 +46,7 @@ public function getConfirmText() { public function buildForm(array $form, array &$form_state) { // Find out how many users are directly assigned to this shortcut set, and // make a message. - $number = $this->storageController->countAssignedUsers($this->entity); + $number = $this->getStorage()->countAssignedUsers($this->entity); $info = ''; if ($number) { $info .= '

' . format_plural($number, diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php index 79683b8..e9ccfd0 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutAccessController.php @@ -45,7 +45,7 @@ public function __construct(EntityTypeInterface $entity_info, ShortcutSetStorage public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) { return new static( $entity_info, - $container->get('entity.manager')->getStorageController('shortcut_set') + $container->get('entity.manager')->getDefinition('shortcut_set')->getStorage() ); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php index 06493ec..a1a8575 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutSetsTest.php @@ -31,7 +31,7 @@ function testShortcutSetAdd() { 'id' => strtolower($this->randomName()), ); $this->drupalPostForm(NULL, $edit, t('Save')); - $new_set = $this->container->get('entity.manager')->getStorageController('shortcut_set')->load($edit['id']); + $new_set = \Drupal::entityManager()->getDefinition('shortcut_set')->getStorage()->load($edit['id']); $this->assertIdentical($new_set->id(), $edit['id'], 'Successfully created a shortcut set.'); $this->drupalGet('user/' . $this->admin_user->id() . '/shortcuts'); $this->assertText($new_set->label(), 'Generated shortcut set was listed as a choice on the user account page.'); diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php index 58b0313..fc10845 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutTestBase.php @@ -111,7 +111,7 @@ function generateShortcutSet($label = '', $id = NULL) { */ function getShortcutInformation(ShortcutSetInterface $set, $key) { $info = array(); - \Drupal::entityManager()->getStorageController('shortcut')->resetCache(); + \Drupal::entityManager()->getDefinition('shortcut')->getStorage()->resetCache(); foreach ($set->getShortcuts() as $shortcut) { $info[] = $shortcut->{$key}->value; } diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 8c7c869..327b27c 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -180,7 +180,7 @@ function shortcut_set_load($id) { */ function shortcut_set_assign_user($shortcut_set, $account) { \Drupal::entityManager() - ->getStorageController('shortcut_set') + ->getDefinition('shortcut_set')->getStorage() ->assignUser($shortcut_set, $account); } @@ -199,7 +199,7 @@ function shortcut_set_assign_user($shortcut_set, $account) { */ function shortcut_set_unassign_user($account) { return (bool) \Drupal::entityManager() - ->getStorageController('shortcut_set') + ->getDefinition('shortcut_set')->getStorage() ->unassignUser($account); } @@ -228,7 +228,7 @@ function shortcut_current_displayed_set($account = NULL) { // If none was found, try to find a shortcut set that is explicitly assigned // to this user. $shortcut_set_name = \Drupal::entityManager() - ->getStorageController('shortcut_set') + ->getDefinition('shortcut_set')->getStorage() ->getAssignedToUser($account); if ($shortcut_set_name) { $shortcut_set = shortcut_set_load($shortcut_set_name); @@ -335,7 +335,7 @@ function shortcut_renderable_links($shortcut_set = NULL) { $shortcut_set = shortcut_current_displayed_set(); } - $shortcuts = \Drupal::entityManager()->getStorageController('shortcut')->loadByProperties(array('shortcut_set' => $shortcut_set->id())); + $shortcuts = \Drupal::entityManager()->getDefinition('shortcut')->getStorage()->loadByProperties(array('shortcut_set' => $shortcut_set->id())); foreach ($shortcuts as $shortcut) { $links[] = array( 'title' => $shortcut->label(), @@ -389,7 +389,7 @@ function shortcut_preprocess_page(&$variables) { $shortcut_set = shortcut_current_displayed_set(); // Check if $link is already a shortcut and set $link_mode accordingly. - $shortcuts = \Drupal::entityManager()->getStorageController('shortcut')->loadByProperties(array('shortcut_set' => $shortcut_set->id())); + $shortcuts = \Drupal::entityManager()->getDefinition('shortcut')->getStorage()->loadByProperties(array('shortcut_set' => $shortcut_set->id())); foreach ($shortcuts as $shortcut) { if ($shortcut->getRouteName() == $route_info[0] && $shortcut->getRouteParams() == $route_info[1]) { $shortcut_id = $shortcut->id(); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index 265012e..6ad5725 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -205,7 +205,7 @@ function __construct($test_id = NULL) { */ function drupalGetNodeByTitle($title, $reset = FALSE) { if ($reset) { - \Drupal::entityManager()->getStorageController('node')->resetCache(); + \Drupal::entityManager()->getDefinition('node')->getStorage()->resetCache(); } $nodes = entity_load_multiple_by_properties('node', array('title' => $title)); // Load the first node returned from the database. diff --git a/core/modules/system/lib/Drupal/system/Controller/SystemController.php b/core/modules/system/lib/Drupal/system/Controller/SystemController.php index 6145a11..195c4a9 100644 --- a/core/modules/system/lib/Drupal/system/Controller/SystemController.php +++ b/core/modules/system/lib/Drupal/system/Controller/SystemController.php @@ -73,7 +73,7 @@ public function overview() { ->condition('link_path', 'admin/config') ->condition('module', 'system'); $result = $query->execute(); - $menu_link_storage = $this->entityManager()->getStorageController('menu_link'); + $menu_link_storage = $this->entityManager()->getDefinition('menu_link')->getStorage(); if ($system_link = $menu_link_storage->loadMultiple($result)) { $system_link = reset($system_link); $query = $this->queryFactory->get('menu_link') diff --git a/core/modules/system/lib/Drupal/system/DateFormatListController.php b/core/modules/system/lib/Drupal/system/DateFormatListController.php index 673730d..bb32267 100644 --- a/core/modules/system/lib/Drupal/system/DateFormatListController.php +++ b/core/modules/system/lib/Drupal/system/DateFormatListController.php @@ -11,9 +11,7 @@ use Drupal\Core\Config\Entity\ConfigEntityListController; use Drupal\Core\Datetime\Date; 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,15 +31,11 @@ class DateFormatListController extends ConfigEntityListController { * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * 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, Date $date_service) { + parent::__construct($entity_info); $this->dateService = $date_service; } @@ -52,8 +46,6 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr 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('date') ); } diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php index bdce06b..6acedac 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php @@ -9,7 +9,6 @@ use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\ReplaceCommand; -use Drupal\Core\Config\Entity\ConfigStorageController; use Drupal\Core\Datetime\Date; use Drupal\Core\Language\Language; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -44,29 +43,19 @@ protected $dateService; /** - * The date format storage controller. - * - * @var \Drupal\Core\Config\Entity\ConfigStorageController - */ - protected $dateFormatStorage; - - /** * Constructs a new date format form. * * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory * The entity query factory. * @param \Drupal\Core\Datetime\Date $date_service * The date service. - * @param \Drupal\Core\Config\Entity\ConfigStorageController $date_format_storage - * The date format storage controller. */ - public function __construct(QueryFactory $query_factory, Date $date_service, ConfigStorageController $date_format_storage) { + public function __construct(QueryFactory $query_factory, Date $date_service) { $date = new DrupalDateTime(); $this->patternType = $date->canUseIntl() ? DrupalDateTime::INTL : DrupalDateTime::PHP; $this->queryFactory = $query_factory; $this->dateService = $date_service; - $this->dateFormatStorage = $date_format_storage; } /** @@ -75,8 +64,7 @@ public function __construct(QueryFactory $query_factory, Date $date_service, Con public static function create(ContainerInterface $container) { return new static( $container->get('entity.query'), - $container->get('date'), - $container->get('entity.manager')->getStorageController('date_format') + $container->get('date') ); } @@ -189,7 +177,7 @@ public function validate(array $form, array &$form_state) { // machine name is available. Regardless of machine_name or human readable // name, check to see if the provided pattern exists. $pattern = trim($form_state['values']['date_format_pattern']); - foreach ($this->dateFormatStorage->loadMultiple() as $format) { + foreach ($this->getStorage()->loadMultiple() as $format) { if ($format->getPattern() == $pattern && ($this->entity->isNew() || $format->id() != $this->entity->id())) { $this->setFormError('date_format_pattern', $form_state, $this->t('This format already exists. Enter a unique format string.')); continue; diff --git a/core/modules/system/lib/Drupal/system/PathBasedBreadcrumbBuilder.php b/core/modules/system/lib/Drupal/system/PathBasedBreadcrumbBuilder.php index f185e48..54c58c9 100644 --- a/core/modules/system/lib/Drupal/system/PathBasedBreadcrumbBuilder.php +++ b/core/modules/system/lib/Drupal/system/PathBasedBreadcrumbBuilder.php @@ -95,7 +95,7 @@ class PathBasedBreadcrumbBuilder extends BreadcrumbBuilderBase { public function __construct(Request $request, EntityManagerInterface $entity_manager, AccessManager $access_manager, RequestMatcherInterface $router, InboundPathProcessorInterface $path_processor, ConfigFactory $config_factory, TitleResolverInterface $title_resolver) { $this->request = $request; $this->accessManager = $access_manager; - $this->menuStorage = $entity_manager->getStorageController('menu'); + $this->menuStorage = $entity_manager->getDefinition('menu')->getStorage(); $this->router = $router; $this->pathProcessor = $path_processor; $this->config = $config_factory->get('system.site'); diff --git a/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php index 5542808..97aeda2 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Derivative/SystemMenuBlock.php @@ -41,7 +41,7 @@ public function __construct(EntityStorageControllerInterface $menu_storage) { */ public static function create(ContainerInterface $container, $base_plugin_id) { return new static( - $container->get('entity.manager')->getStorageController('menu') + $container->get('entity.manager')->getDefinition('menu')->getStorage() ); } diff --git a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php index ceee2e2..09b43f9 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php +++ b/core/modules/system/lib/Drupal/system/Plugin/views/field/BulkFormBase.php @@ -64,7 +64,7 @@ public function buildOptionsForm(&$form, &$form_state) { public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManagerInterface $manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->actions = $manager->getStorageController('action')->loadMultiple(); + $this->actions = $manager->getDefinition('action')->getStorage()->loadMultiple(); } /** diff --git a/core/modules/system/lib/Drupal/system/SystemManager.php b/core/modules/system/lib/Drupal/system/SystemManager.php index 07e8c0a..a854d7a 100644 --- a/core/modules/system/lib/Drupal/system/SystemManager.php +++ b/core/modules/system/lib/Drupal/system/SystemManager.php @@ -73,7 +73,7 @@ class SystemManager { public function __construct(ModuleHandlerInterface $module_handler, Connection $database, EntityManagerInterface $entity_manager) { $this->moduleHandler = $module_handler; $this->database = $database; - $this->menuLinkStorage = $entity_manager->getStorageController('menu_link'); + $this->menuLinkStorage = $entity_manager->getDefinition('menu_link')->getStorage(); } /** diff --git a/core/modules/system/lib/Drupal/system/Tests/Action/ActionUnitTest.php b/core/modules/system/lib/Drupal/system/Tests/Action/ActionUnitTest.php index 96f2d73..d4b5ab4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Action/ActionUnitTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Action/ActionUnitTest.php @@ -70,7 +70,7 @@ public function testOperations() { // Create a new unsaved user. $name = $this->randomName(); - $user_storage = $this->container->get('entity.manager')->getStorageController('user'); + $user_storage = \Drupal::entityManager()->getDefinition('user')->getStorage(); $account = $user_storage->create(array('name' => $name, 'bundle' => 'user')); $loaded_accounts = $user_storage->loadMultiple(); $this->assertEqual(count($loaded_accounts), 0); diff --git a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php index 4511346..15e747e 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Common/FormatDateTest.php @@ -42,7 +42,7 @@ function setUp() { ->set('timezone.user.configurable', 1) ->save(); $formats = $this->container->get('entity.manager') - ->getStorageController('date_format') + ->getDefinition('date_format')->getStorage() ->loadMultiple(array('long', 'medium', 'short')); $formats['long']->setPattern('l, j. F Y - G:i')->save(); $formats['medium']->setPattern('j. F Y - G:i')->save(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Datetime/DateTimePlusIntlTest.php b/core/modules/system/lib/Drupal/system/Tests/Datetime/DateTimePlusIntlTest.php index b38f955..9523062 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Datetime/DateTimePlusIntlTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Datetime/DateTimePlusIntlTest.php @@ -77,7 +77,7 @@ function testDateTimestampIntl() { $this->assertFalse($php_date->canUseIntl(), 'DateTimePlus object will fallback to use PHP when not provided with country setting.'); $default_formats = $this->container->get('entity.manager') - ->getStorageController('date_format') + ->getDefinition('date_format')->getStorage() ->loadMultiple(); foreach ($default_formats as $format) { diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php index 373c90b..1056abd 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityAccessTest.php @@ -94,7 +94,7 @@ function testEntityAccessDefaultController() { // Check that the default access controller is used for entities that don't // have a specific access controller defined. - $controller = $this->container->get('entity.manager')->getAccessController('entity_test_default_access'); + $controller = \Drupal::entityManager()->getDefinition('entity_test_default_access')->getAccess(); $this->assertTrue($controller instanceof EntityAccessController, 'The default entity controller is used for the entity_test_default_access entity type.'); $entity = entity_create('entity_test_default_access', array()); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php index 3fa3533..09891f7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php @@ -95,7 +95,7 @@ protected function assertFormCRUD($entity_type) { protected function loadEntityByName($entity_type, $name) { // Always load the entity from the database to ensure that changes are // correctly picked up. - $this->container->get('entity.manager')->getStorageController($entity_type)->resetCache(); + \Drupal::entityManager()->getDefinition($entity_type)->getStorage()->resetCache(); return current(entity_load_multiple_by_properties($entity_type, array('name' => $name))); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityManagerTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityManagerTest.php deleted file mode 100644 index 7cbe7b5..0000000 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityManagerTest.php +++ /dev/null @@ -1,42 +0,0 @@ - 'Entity Manager', - 'description' => 'Tests methods on the entity manager.', - 'group' => 'Entity API', - ); - } - - /** - * Tests some methods on the manager. - */ - public function testMethods() { - // Tests the has controller method. - $entity_manager = $this->container->get('entity.manager'); - $this->assertEqual(spl_object_hash($entity_manager), spl_object_hash($this->container->get('entity.manager'))); - - $this->assertFalse($entity_manager->hasController('non_existent', 'storage'), 'A non existent entity type has no controller.'); - $this->assertFalse($entity_manager->hasController('non_existent', 'non_existent'), 'A non existent entity type has no controller.'); - - $this->assertFalse($entity_manager->hasController('entity_test', 'non_existent'), 'An existent entity type does not have a non existent controller.'); - $this->assertFalse($entity_manager->hasController('entity_test_mulrev', 'view_builder'), 'The test entity does not have specified the view builder.'); - - $this->assertTrue($entity_manager->hasController('entity_test', 'storage'), 'The test entity has specified the controller class'); - } - -} diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php index 7f7d2c4..b1f216a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityQueryAggregateTest.php @@ -52,7 +52,7 @@ public static function getInfo() { public function setUp() { parent::setUp(); - $this->entityStorageController = $this->container->get('entity.manager')->getStorageController('entity_test'); + $this->entityStorageController = \Drupal::entityManager()->getDefinition('entity_test')->getStorage(); $this->factory = $this->container->get('entity.query'); // Add some fieldapi fields to be used in the test. diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index a084ebf..a866735 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -293,7 +293,7 @@ function testEntityTranslationAPI() { $default_langcode = $this->langcodes[0]; $langcode = $this->langcodes[1]; $entity = $this->entityManager - ->getStorageController('entity_test_mul') + ->getDefinition('entity_test_mul')->getStorage() ->create(array('name' => $this->randomName())); $entity->save(); @@ -433,7 +433,7 @@ function testEntityTranslationAPI() { // Check that per-language defaults are properly populated. $entity = $this->reloadEntity($entity); $instance_id = implode('.', array($entity->entityType(), $entity->bundle(), $this->field_name)); - $instance = $this->entityManager->getStorageController('field_instance')->load($instance_id); + $instance = $this->entityManager->getDefinition('field_instance')->getStorage()->load($instance_id); $instance->default_value_function = 'entity_test_field_default_value'; $instance->save(); $translation = $entity->addTranslation($langcode2); @@ -460,7 +460,7 @@ function testLanguageFallback() { $langcode2 = $this->langcodes[2]; $entity_type = 'entity_test_mul'; - $controller = $this->entityManager->getStorageController($entity_type); + $controller = $this->entityManager->getDefinition($entity_type)->getStorage(); $entity = $controller->create(array('langcode' => $default_langcode) + $values[$default_langcode]); $entity->save(); @@ -492,7 +492,7 @@ function testLanguageFallback() { $this->assertIdentical($entity2, $translation, 'When the entity has no translation no fallback is applied.'); // Checks that entity translations are rendered properly. - $controller = $this->entityManager->getViewBuilder($entity_type); + $controller = $this->entityManager->getDefinition($entity_type)->getViewBuilder(); $build = $controller->view($entity); $this->assertEqual($build['label']['#markup'], $values[$current_langcode]['name'], 'By default the entity is rendered in the current language.'); $langcodes = MapArray::copyValuesToKeys($this->langcodes); @@ -548,7 +548,7 @@ function testFieldDefinitions() { */ public function testLanguageChange() { $entity_type = 'entity_test_mul'; - $controller = $this->entityManager->getStorageController($entity_type); + $controller = $this->entityManager->getDefinition($entity_type)->getStorage(); $langcode = $this->langcodes[0]; // check that field languages match entity language regardless of field diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php index ccf6070..37e3b99 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php @@ -91,7 +91,7 @@ protected function createUser($values = array(), $permissions = array()) { * The reloaded entity. */ protected function reloadEntity(EntityInterface $entity) { - $controller = $this->entityManager->getStorageController($entity->entityType()); + $controller = $this->entityManager->getDefinition($entity->entityType()->getStorage()); $controller->resetCache(array($entity->id())); return $controller->load($entity->id()); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewBuilderTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewBuilderTest.php index ab1c086..ce91629 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewBuilderTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewBuilderTest.php @@ -47,12 +47,12 @@ public function testEntityViewBuilderCache() { // Test that new entities (before they are saved for the first time) do not // generate a cache entry. - $build = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test, 'full'); + $build = \Drupal::entityManager()->getDefinition('entity_test')->getViewBuilder()->view($entity_test, 'full'); $this->assertFalse(isset($build['#cache']), 'The render array element of new (unsaved) entities is not cached.'); // Get a fully built entity view render array. $entity_test->save(); - $build = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test, 'full'); + $build = \Drupal::entityManager()->getDefinition('entity_test')->getViewBuilder()->view($entity_test, 'full'); $cid = drupal_render_cid_create($build); $bin = $build['#cache']['bin']; @@ -95,7 +95,7 @@ public function testEntityViewBuilderCacheWithReferences() { $entity_test_reference->save(); // Get a fully built entity view render array for the referenced entity. - $build = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test_reference, 'full'); + $build = \Drupal::entityManager()->getDefinition('entity_test')->getViewBuilder()->view($entity_test_reference, 'full'); $cid_reference = drupal_render_cid_create($build); $bin_reference = $build['#cache']['bin']; @@ -113,7 +113,7 @@ public function testEntityViewBuilderCacheWithReferences() { $entity_test->save(); // Get a fully built entity view render array. - $build = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test, 'full'); + $build = \Drupal::entityManager()->getDefinition('entity_test')->getViewBuilder()->view($entity_test, 'full'); $cid = drupal_render_cid_create($build); $bin = $build['#cache']['bin']; @@ -143,17 +143,17 @@ public function testEntityViewBuilderCacheToggling() { // Test a view mode in default conditions: render caching is enabled for // the entity type and the view mode. - $build = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test, 'full'); + $build = \Drupal::entityManager()->getDefinition('entity_test')->getViewBuilder()->view($entity_test, 'full'); $this->assertTrue(isset($build['#cache']), 'A view mode with render cache enabled has the correct output.'); // Test that a view mode can opt out of render caching. - $build = $this->container->get('entity.manager')->getViewBuilder('entity_test')->view($entity_test, 'test'); + $build = \Drupal::entityManager()->getDefinition('entity_test')->getViewBuilder()->view($entity_test, 'test'); $this->assertFalse(isset($build['#cache']), 'A view mode with render cache disabled has the correct output.'); // Test that an entity type can opt out of render caching completely. $entity_test_no_cache = $this->createTestEntity('entity_test_label'); $entity_test_no_cache->save(); - $build = $this->container->get('entity.manager')->getViewBuilder('entity_test_label')->view($entity_test_no_cache, 'full'); + $build = \Drupal::entityManager()->getDefinition('entity_test_label')->getViewBuilder()->view($entity_test_no_cache, 'full'); $this->assertFalse(isset($build['#cache']), 'An entity type can opt out of render caching regardless of view mode configuration.'); } @@ -171,7 +171,7 @@ protected function createTestEntity($entity_type) { 'bundle' => $entity_type, 'name' => $this->randomName(), ); - return $this->container->get('entity.manager')->getStorageController($entity_type)->create($data); + return \Drupal::entityManager()->getDefinition($entity_type)->getStorage()->create($data); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php index d08d45a..4d71a67 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php @@ -43,7 +43,7 @@ function setUp() { for ($i = 0; $i < 2; $i++) { $random_label = $this->randomName(); $data = array('bundle' => 'entity_test', 'name' => $random_label); - $entity_test = $this->container->get('entity.manager')->getStorageController('entity_test')->create($data); + $entity_test = \Drupal::entityManager()->getDefinition('entity_test')->getStorage()->create($data); $entity_test->save(); $this->entities[] = $entity_test; } @@ -101,7 +101,7 @@ public function testFieldItemAttributes() { ))->save(); // Browse to the entity and verify that the attributes from both modules // are rendered in the field item HTML markup. - \Drupal::entityManager()->getViewBuilder('entity_test')->resetCache(array($entity)); + \Drupal::entityManager()->getDefinition('entity_test')->getViewBuilder()->resetCache(array($entity)); $this->drupalGet('entity_test/' . $entity->id()); $xpath = $this->xpath('//div[@data-field-item-attr="foobar" and @property="schema:text" and text()=:value]', array(':value' => $test_value)); $this->assertTrue($xpath, 'The field item attributes from both modules have been found in the rendered output of the field.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php index 45d997f..5bc013c 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldSqlStorageTest.php @@ -94,7 +94,7 @@ function setUp() { */ function testFieldLoad() { $entity_type = $bundle = 'entity_test_rev'; - $storage_controller = $this->container->get('entity.manager')->getStorageController($entity_type); + $storage_controller = \Drupal::entityManager()->getDefinition($entity_type)->getStorage(); $columns = array('bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode', FieldableDatabaseStorageController::_fieldColumnName($this->field, 'value')); @@ -259,7 +259,7 @@ function testFieldWrite() { function testLongNames() { // Use one of the longest entity_type names in core. $entity_type = $bundle = 'entity_test_label_callback'; - $storage_controller = $this->container->get('entity.manager')->getStorageController($entity_type); + $storage_controller = \Drupal::entityManager()->getDefinition($entity_type)->getStorage(); // Create two fields with instances, and generate randome values. $name_base = drupal_strtolower($this->randomName(Field::NAME_MAX_LENGTH - 1)); @@ -411,7 +411,7 @@ function testFieldUpdateIndexesWithData() { // Verify that the tables were not dropped in the process. field_cache_clear(); - $entity = $this->container->get('entity.manager')->getStorageController($entity_type)->load(1); + $entity = \Drupal::entityManager()->getDefinition($entity_type)->getStorage()->load(1); $this->assertEqual($entity->$field_name->value, 'field data', t("Index changes performed without dropping the tables")); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php index b6790aa..c1fb899 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php @@ -31,7 +31,7 @@ public static function getInfo() { public function testFieldSqlStorage() { $entity_type = 'entity_test_mul'; - $controller = $this->entityManager->getStorageController($entity_type); + $controller = $this->entityManager->getDefinition($entity_type)->getStorage(); $values = array( $this->field_name => $this->randomName(), $this->untranslatable_field_name => $this->randomName(), diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/LocalTasksTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/LocalTasksTest.php index bf51856..65fd387 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/LocalTasksTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/LocalTasksTest.php @@ -201,7 +201,7 @@ public function testPluginLocalTask() { // Test that we we correctly apply the active class to tabs where one of the // request attributes is upcast to an entity object. - $entity = \Drupal::entityManager()->getStorageController('entity_test')->create(array('bundle' => 'test')); + $entity = \Drupal::entityManager()->getDefinition('entity_test')->getStorage()->create(array('bundle' => 'test')); $entity->save(); $this->drupalGet('menu-local-task-test-upcasting/1/sub1'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/TreeOutputTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/TreeOutputTest.php index 78a00aa..8949906 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/TreeOutputTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/TreeOutputTest.php @@ -39,7 +39,7 @@ function setUp() { * Validate the generation of a proper menu tree output. */ function testMenuTreeData() { - $storage_controller = $this->container->get('entity.manager')->getStorageController('menu_link'); + $storage_controller = \Drupal::entityManager()->getDefinition('menu_link')->getStorage(); // @todo Prettify this tree buildup code, it's very hard to read. $this->tree_data = array( '1'=> array( diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index cabea75..3081ed6 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -709,7 +709,7 @@ function hook_contextual_links_alter(array &$links, $group, array $route_paramet if ($group == 'menu') { // Dynamically use the menu name for the title of the menu_edit contextual // link. - $menu = \Drupal::entityManager()->getStorageController('menu')->load($route_parameters['menu']); + $menu = \Drupal::entityManager()->getDefinition('menu')->getStorage()->load($route_parameters['menu']); $links['menu_edit']['title'] = t('Edit menu: !label', array('!label' => $menu->label())); } } diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php index 40dd178..64fa4de 100644 --- a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php +++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php @@ -28,7 +28,7 @@ public function twoFormInstances() { 'type' => 'page', 'langcode' => Language::LANGCODE_NOT_SPECIFIED, ); - $node1 = $this->entityManager()->getStorageController('node')->create($values); + $node1 = $this->entityManager()->getDefinition('node')->getStorage()->create($values); $node2 = clone($node1); $return['node_form_1'] = $this->entityManager()->getForm($node1); $return['node_form_2'] = $this->entityManager()->getForm($node2); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php index e79c37c..9650391 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php @@ -28,7 +28,7 @@ class TaxonomyController extends ControllerBase { * The taxonomy term add form. */ public function addForm(VocabularyInterface $taxonomy_vocabulary) { - $term = $this->entityManager()->getStorageController('taxonomy_term')->create(array('vid' => $taxonomy_vocabulary->id())); + $term = $taxonomy_vocabulary->entityInfo()->getStorage()->create(array('vid' => $taxonomy_vocabulary->id())); if ($this->moduleHandler()->moduleExists('language')) { $term->langcode = language_get_default_langcode('taxonomy_term', $taxonomy_vocabulary->id()); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php index 9d76424..ed13969 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TermAutocompleteController.php @@ -69,7 +69,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('entity.query')->get('taxonomy_term'), $container->get('field.info'), - $container->get('entity.manager')->getStorageController('taxonomy_term') + $container->get('entity.manager')->getDefinition('taxonomy_term')->getStorage() ); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php index b9d810d..323047d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php @@ -59,7 +59,7 @@ public function getConfirmText() { */ public function submit(array $form, array &$form_state) { $this->entity->delete(); - $storage_controller = $this->entityManager->getStorageController('taxonomy_vocabulary'); + $storage_controller = $this->entityManager->getDefinition('taxonomy_vocabulary')->getStorage(); $vocabulary = $storage_controller->load($this->entity->bundle()); // @todo Move to storage controller http://drupal.org/node/1988712 diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php index 9f9e255..216bd62 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php @@ -8,8 +8,6 @@ namespace Drupal\taxonomy\Form; use Drupal\Core\Entity\EntityConfirmFormBase; -use Drupal\taxonomy\TermStorageControllerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Provides confirmation form for resetting a vocabulary to alphabetical order. @@ -17,32 +15,6 @@ class VocabularyResetForm extends EntityConfirmFormBase { /** - * The term storage. - * - * @var \Drupal\taxonomy\TermStorageControllerInterface - */ - protected $termStorage; - - /** - * Constructs a new VocabularyResetForm object. - * - * @param \Drupal\taxonomy\TermStorageControllerInterface $term_storage - * The term storage. - */ - public function __construct(TermStorageControllerInterface $term_storage) { - $this->termStorage = $term_storage; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static( - $container->get('entity.manager')->getStorageController('taxonomy_term') - ); - } - - /** * {@inheritdoc} */ public function getFormId() { @@ -86,7 +58,7 @@ public function getConfirmText() { * {@inheritdoc} */ public function save(array $form, array &$form_state) { - $this->termStorage->resetWeights($this->entity->id()); + $this->getStorage()->resetWeights($this->entity->id()); drupal_set_message($this->t('Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()))); watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); $form_state['redirect_route'] = array( diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php index 42f6ee8..f2545a9 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceFieldItemList.php @@ -31,7 +31,8 @@ protected function getDefaultValue() { ->condition('uuid', $uuids, 'IN') ->execute(); $entities = \Drupal::entityManager() - ->getStorageController('taxonomy_term') + ->getDefinition('taxonomy_term') + ->getStorage() ->loadMultiple($entity_ids); foreach ($entities as $id => $entity) { @@ -66,7 +67,8 @@ public function defaultValuesFormSubmit(array $element, array &$form, array &$fo $ids[] = $properties['target_id']; } $entities = \Drupal::entityManager() - ->getStorageController('taxonomy_term') + ->getDefinition('taxonomy_term') + ->getStorage() ->loadMultiple($ids); foreach ($default_value as $delta => $properties) { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/TermName.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/TermName.php index bbddc4b..b74eb7b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/TermName.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_validator/TermName.php @@ -37,7 +37,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi parent::__construct($configuration, $plugin_id, $plugin_definition, $entity_manager); // Not handling exploding term names. $this->multipleCapable = FALSE; - $this->termStorageController = $entity_manager->getStorageController('taxonomy_term'); + $this->termStorageController = $entity_manager->getDefinition('taxonomy_term')->getStorage(); } /** diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index 925d83c..4fe2467 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -54,8 +54,7 @@ public static function create(ContainerInterface $container) { */ public function form(array $form, array &$form_state) { $term = $this->entity; - $vocab_storage = $this->entityManager->getStorageController('taxonomy_vocabulary'); - $vocabulary = $vocab_storage->load($term->bundle()); + $vocabulary = $this->getStorage()->load($term->bundle()); $parent = array_keys(taxonomy_term_load_parents($term->id())); $form_state['taxonomy']['parent'] = $parent; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php index cf9042d..fedb58c 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php @@ -96,7 +96,7 @@ function testTaxonomyAdminChangingWeights() { $this->drupalPostForm('admin/structure/taxonomy', $edit, t('Save')); // Load the vocabularies from the database. - $this->container->get('entity.manager')->getStorageController('taxonomy_vocabulary')->resetCache(); + \Drupal::entityManager()->getDefinition('taxonomy_vocabulary')->getStorage()->resetCache(); $new_vocabularies = entity_load_multiple('taxonomy_vocabulary'); taxonomy_vocabulary_sort($new_vocabularies); @@ -136,7 +136,7 @@ function testTaxonomyAdminDeletingVocabulary() { $this->assertText(t('Created new vocabulary'), 'New vocabulary was created.'); // Check the created vocabulary. - $this->container->get('entity.manager')->getStorageController('taxonomy_vocabulary')->resetCache(); + \Drupal::entityManager()->getDefinition('taxonomy_vocabulary')->getStorage()->resetCache(); $vocabulary = entity_load('taxonomy_vocabulary', $vid); $this->assertTrue($vocabulary, 'Vocabulary found.'); @@ -149,7 +149,7 @@ function testTaxonomyAdminDeletingVocabulary() { // Confirm deletion. $this->drupalPostForm(NULL, NULL, t('Delete')); $this->assertRaw(t('Deleted vocabulary %name.', array('%name' => $vocabulary->name)), 'Vocabulary deleted.'); - $this->container->get('entity.manager')->getStorageController('taxonomy_vocabulary')->resetCache(); + \Drupal::entityManager()->getDefinition('taxonomy_vocabulary')->getStorage()->resetCache(); $this->assertFalse(entity_load('taxonomy_vocabulary', $vid), 'Vocabulary not found.'); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php index c11f865..ea55647 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyUnitTest.php @@ -135,7 +135,7 @@ function testTaxonomyVocabularyLoadMultiple() { $this->assertEqual(array_shift($vocabularies)->id(), $vocabulary1->id(), 'Vocabulary loaded successfully by ID.'); // Test loading vocabularies by their properties. - $controller = $this->container->get('entity.manager')->getStorageController('taxonomy_vocabulary'); + $controller = \Drupal::entityManager()->getDefinition('taxonomy_vocabulary')->getStorage(); // Fetch vocabulary 1 by name. $vocabulary = current($controller->loadByProperties(array('name' => $vocabulary1->name))); $this->assertEqual($vocabulary->id(), $vocabulary1->id(), 'Vocabulary loaded successfully by name.'); diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index e41b467..2e8b613 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -425,7 +425,7 @@ function taxonomy_term_is_page(Term $term) { * Clear all static cache variables for terms. */ function taxonomy_terms_static_reset() { - \Drupal::entityManager()->getStorageController('taxonomy_term')->resetCache(); + \Drupal::entityManager()->getDefinition('taxonomy_term')->getStorage()->resetCache(); } /** @@ -435,7 +435,7 @@ function taxonomy_terms_static_reset() { * An array of ids to reset in entity controller cache. */ function taxonomy_vocabulary_static_reset(array $ids = NULL) { - \Drupal::entityManager()->getStorageController('taxonomy_vocabulary')->resetCache($ids); + \Drupal::entityManager()->getDefinition('taxonomy_vocabulary')->getStorage()->resetCache($ids); } /** @@ -473,7 +473,7 @@ function taxonomy_term_load_parents($tid) { $parents = &drupal_static(__FUNCTION__, array()); if ($tid && !isset($parents[$tid])) { - $tids = \Drupal::entityManager()->getStorageController('taxonomy_term')->loadParents($tid); + $tids = \Drupal::entityManager()->getDefinition('taxonomy_term')->getStorage()->loadParents($tid); $parents[$tid] = entity_load_multiple('taxonomy_term', $tids); } @@ -521,7 +521,7 @@ function taxonomy_term_load_children($tid, $vid = NULL) { $children = &drupal_static(__FUNCTION__, array()); if ($tid && !isset($children[$tid])) { - $tids = \Drupal::entityManager()->getStorageController('taxonomy_term')->loadChildren($tid); + $tids = \Drupal::entityManager()->getDefinition('taxonomy_term')->getStorage()->loadChildren($tid); $children[$tid] = entity_load_multiple('taxonomy_term', $tids); } @@ -562,7 +562,7 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $load_entities $parents[$vid] = array(); $terms[$vid] = array(); - $result = \Drupal::entityManager()->getStorageController('taxonomy_term')->loadTree($vid); + $result = \Drupal::entityManager()->getDefinition('taxonomy_term')->getStorage()->loadTree($vid); foreach ($result as $term) { $children[$vid][$term->parent][] = $term->tid; @@ -863,7 +863,7 @@ function taxonomy_node_insert(EntityInterface $node) { function taxonomy_build_node_index($node) { // We maintain a denormalized table of term/node relationships, containing // only data for current, published nodes. - if (!\Drupal::config('taxonomy.settings')->get('maintain_index_table') || !(\Drupal::entityManager()->getStorageController('node') instanceof FieldableDatabaseStorageController)) { + if (!\Drupal::config('taxonomy.settings')->get('maintain_index_table') || !(\Drupal::entityManager()->getDefinition('node')->getStorage() instanceof FieldableDatabaseStorageController)) { return; } diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc index ce77a7c..93f9f12 100644 --- a/core/modules/taxonomy/taxonomy.tokens.inc +++ b/core/modules/taxonomy/taxonomy.tokens.inc @@ -175,7 +175,7 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options = break; case 'node-count': - $replacements[$original] = \Drupal::entityManager()->getStorageController('taxonomy_term')->nodeCount($vocabulary->id()); + $replacements[$original] = \Drupal::entityManager()->getDefinition('taxonomy_term')->getStorage()->nodeCount($vocabulary->id()); break; } } diff --git a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php index f209a44..f74016f 100644 --- a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php @@ -251,7 +251,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { $this->assertText(t('entity_test @id has been updated.', array('@id' => $id)), 'Entity was updated'); // Display the entity. - $this->container->get('entity.manager')->getStorageController('entity_test')->resetCache(array($id)); + \Drupal::entityManager()->getDefinition('entity_test')->getStorage()->resetCache(array($id)); $entity = entity_load('entity_test', $id); $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full'); $entity->content = field_attach_view($entity, $display); diff --git a/core/modules/user/lib/Drupal/user/Controller/UserListController.php b/core/modules/user/lib/Drupal/user/Controller/UserListController.php index 4d2a406..89e41fa 100644 --- a/core/modules/user/lib/Drupal/user/Controller/UserListController.php +++ b/core/modules/user/lib/Drupal/user/Controller/UserListController.php @@ -10,10 +10,8 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityListController; -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; /** @@ -35,15 +33,11 @@ class UserListController extends EntityListController implements EntityControlle * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info * 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, QueryFactory $query_factory) { + parent::__construct($entity_info); $this->queryFactory = $query_factory; } @@ -53,8 +47,6 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr 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.query') ); } diff --git a/core/modules/user/lib/Drupal/user/Entity/User.php b/core/modules/user/lib/Drupal/user/Entity/User.php index 2954df5..24a1e2c 100644 --- a/core/modules/user/lib/Drupal/user/Entity/User.php +++ b/core/modules/user/lib/Drupal/user/Entity/User.php @@ -225,7 +225,7 @@ public function hasPermission($permission) { return TRUE; } - $roles = \Drupal::entityManager()->getStorageController('user_role')->loadMultiple($this->getRoles()); + $roles = \Drupal::entityManager()->getDefinition('user_role')->getStorage()->loadMultiple($this->getRoles()); foreach ($roles as $role) { if ($role->hasPermission($permission)) { diff --git a/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php b/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php index 46744a4..a191d4c 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php @@ -50,7 +50,7 @@ public function __construct(FloodInterface $flood, UserStorageControllerInterfac public static function create(ContainerInterface $container) { return new static( $container->get('flood'), - $container->get('entity.manager')->getStorageController('user') + $container->get('entity.manager')->getDefinition('user')->getStorage() ); } diff --git a/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php b/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php index ba85502..d625849 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php @@ -76,7 +76,7 @@ public static function create(ContainerInterface $container) { return new static( $container->get('user.tempstore'), $container->get('config.factory'), - $container->get('entity.manager')->getStorageController('user'), + $container->get('entity.manager')->getDefinition('user')->getStorage(), $container->get('entity.manager') ); } @@ -199,7 +199,7 @@ public function submitForm(array &$form, array &$form_state) { // The $user global is not a complete user entity, so load the full // entity. $account = $this->userStorage->load($uid); - $admin_form = $this->entityManager->getFormController('user', 'cancel'); + $admin_form = $this->entityManager->getDefinition('user')->getForm('cancel'); $admin_form->setEntity($account); // Calling this directly required to init form object with $account. $admin_form->buildForm($admin_form_mock, $admin_form_state, $this->request); diff --git a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php index 07d35e9..87b83e2 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php @@ -51,7 +51,7 @@ public function __construct(UserStorageControllerInterface $user_storage_control */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('user'), + $container->get('entity.manager')->getDefinition('user')->getStorage(), $container->get('language_manager') ); } diff --git a/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php b/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php index a0b29ee..87da896 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserPermissionsForm.php @@ -52,7 +52,7 @@ public function __construct(ModuleHandlerInterface $module_handler, RoleStorageC public static function create(ContainerInterface $container) { return new static( $container->get('module_handler'), - $container->get('entity.manager')->getStorageController('user_role') + $container->get('entity.manager')->getDefinition('user_role')->getStorage() ); } diff --git a/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php index ea5f417..b570b3e 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Search/UserSearch.php @@ -137,7 +137,7 @@ public function execute() { ->limit(15) ->execute() ->fetchCol(); - $accounts = $this->entityManager->getStorageController('user')->loadMultiple($uids); + $accounts = $this->entityManager->getDefinition('user')->getStorage()->loadMultiple($uids); foreach ($accounts as $account) { $result = array( diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument/RolesRid.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument/RolesRid.php index 743d6cd..95e844d 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/argument/RolesRid.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument/RolesRid.php @@ -43,7 +43,7 @@ class RolesRid extends ManyToOne { public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManagerInterface $entity_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->roleStorageController = $entity_manager->getStorageController('user_role'); + $this->roleStorageController = $entity_manager->getDefinition('user_role')->getStorage(); } /** diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument/Uid.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument/Uid.php index 0c299d1..c5a8e83 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/argument/Uid.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument/Uid.php @@ -50,7 +50,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { return new static($configuration, $plugin_id, $plugin_definition, - $container->get('entity.manager')->getStorageController('user')); + $container->get('entity.manager')->getDefinition('user')->getStorage()); } /** diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/Permissions.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/Permissions.php index dc55c92..eac700d 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/Permissions.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/Permissions.php @@ -54,7 +54,7 @@ class Permissions extends PrerenderList { public function __construct(array $configuration, $plugin_id, array $plugin_definition, ModuleHandlerInterface $module_handler, EntityManagerInterface $entity_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->roleStorageController = $entity_manager->getStorageController('user_role'); + $this->roleStorageController = $entity_manager->getDefinition('user_role')->getStorage(); $this->moduleHandler = $module_handler; } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserEntityTest.php b/core/modules/user/lib/Drupal/user/Tests/UserEntityTest.php index 8532008..2c4e54a 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserEntityTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserEntityTest.php @@ -41,7 +41,7 @@ public static function getInfo() { * @see \Drupal\user\Entity\User::removeRole() */ public function testUserMethods() { - $role_storage = $this->container->get('entity.manager')->getStorageController('user_role'); + $role_storage = \Drupal::entityManager()->getDefinition('user_role')->getStorage(); $role_storage->create(array('id' => 'test_role_one'))->save(); $role_storage->create(array('id' => 'test_role_two'))->save(); $role_storage->create(array('id' => 'test_role_three'))->save(); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php index 06d4994..b1f702f 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserPermissionsTest.php @@ -51,7 +51,7 @@ function testUserPermissionChanges() { $edit[$rid . '[administer nodes]'] = TRUE; $this->drupalPostForm('admin/people/permissions', $edit, t('Save permissions')); $this->assertText(t('The changes have been saved.'), 'Successful save message displayed.'); - $storage_controller = $this->container->get('entity.manager')->getStorageController('user_role'); + $storage_controller = \Drupal::entityManager()->getDefinition('user_role')->getStorage(); $storage_controller->resetCache(); $this->assertTrue(user_access('administer nodes', $account), 'User now has "administer nodes" permission.'); $current_permissions_hash = $permissions_hash_generator->generate($account); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php index 8b6bb8c..b14cda3 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserRegistrationTest.php @@ -55,7 +55,7 @@ function testRegistrationWithEmailVerification() { $edit['name'] = $name = $this->randomName(); $edit['mail'] = $mail = $edit['name'] . '@example.com'; $this->drupalPostForm('user/register', $edit, t('Create new account')); - $this->container->get('entity.manager')->getStorageController('user')->resetCache(); + \Drupal::entityManager()->getDefinition('user')->getStorage()->resetCache(); $accounts = entity_load_multiple_by_properties('user', array('name' => $name, 'mail' => $mail)); $new_user = reset($accounts); $this->assertFalse($new_user->isActive(), 'New account is blocked until approved by an administrator.'); @@ -84,7 +84,7 @@ function testRegistrationWithoutEmailVerification() { $edit['pass[pass1]'] = $new_pass = $this->randomName(); $edit['pass[pass2]'] = $new_pass; $this->drupalPostForm('user/register', $edit, t('Create new account')); - $this->container->get('entity.manager')->getStorageController('user')->resetCache(); + \Drupal::entityManager()->getDefinition('user')->getStorage()->resetCache(); $accounts = entity_load_multiple_by_properties('user', array('name' => $name, 'mail' => $mail)); $new_user = reset($accounts); $this->assertNotNull($new_user, 'New account successfully created with matching passwords.'); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleTest.php b/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleTest.php index df4a6a7..bfe5746 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleTest.php @@ -39,7 +39,7 @@ public static function getInfo() { */ function testAccessRole() { /** @var \Drupal\views\ViewStorageInterface $view */ - $view = \Drupal::entityManager()->getStorageController('view')->load('test_access_role'); + $view = \Drupal::entityManager()->getDefinition('view')->getStorage()->load('test_access_role'); $display = &$view->getDisplay('default'); $display['display_options']['access']['options']['role'] = array( $this->normalRole => $this->normalRole, diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleUITest.php b/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleUITest.php index 3ae1dc6..22377db 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleUITest.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/AccessRoleUITest.php @@ -55,14 +55,14 @@ protected function setUp() { * Tests the role access plugin UI. */ public function testAccessRoleUI() { - $entity_manager = $this->container->get('entity.manager'); - $entity_manager->getStorageController('user_role')->create(array('id' => 'custom_role', 'label' => 'Custom role'))->save(); + $entity_manager = \Drupal::entityManager(); + $entity_manager->getDefinition('user_role')->getStorage()->create(array('id' => 'custom_role', 'label' => 'Custom role'))->save(); $access_url = "admin/structure/views/nojs/display/test_access_role/default/access_options"; $this->drupalPostForm($access_url, array('access_options[role][custom_role]' => 1), t('Apply')); $this->assertResponse(200); $this->drupalPostForm(NULL, array(), t('Save')); - $view = $entity_manager->getStorageController('view')->load('test_access_role'); + $view = $entity_manager->getDefinition('view')->getStorage()->load('test_access_role'); $display = $view->getDisplay('default'); $this->assertEqual($display['display_options']['access']['options']['role'], array('custom_role' => 'custom_role')); diff --git a/core/modules/user/lib/Drupal/user/Tests/Views/UserUnitTestBase.php b/core/modules/user/lib/Drupal/user/Tests/Views/UserUnitTestBase.php index bec7c5a..291c356 100644 --- a/core/modules/user/lib/Drupal/user/Tests/Views/UserUnitTestBase.php +++ b/core/modules/user/lib/Drupal/user/Tests/Views/UserUnitTestBase.php @@ -51,9 +51,9 @@ protected function setUp() { $this->installSchema('user', array('users', 'users_roles')); $this->installSchema('system', 'sequences'); - $entity_manager = $this->container->get('entity.manager'); - $this->roleStorageController = $entity_manager->getStorageController('user_role'); - $this->userStorageController = $entity_manager->getStorageController('user'); + $entity_manager = \Drupal::entityManager(); + $this->roleStorageController = $entity_manager->getDefinition('user_role')->getStorage(); + $this->userStorageController = $entity_manager->getDefinition('user')->getStorage(); } /** diff --git a/core/modules/user/lib/Drupal/user/Theme/AdminNegotiator.php b/core/modules/user/lib/Drupal/user/Theme/AdminNegotiator.php index faaeb40..7406662 100644 --- a/core/modules/user/lib/Drupal/user/Theme/AdminNegotiator.php +++ b/core/modules/user/lib/Drupal/user/Theme/AdminNegotiator.php @@ -60,7 +60,7 @@ public function __construct(AccountInterface $user, ConfigFactory $config_factor */ public function applies(Request $request) { $path = $request->attributes->get('_system_path'); - return ($this->entityManager->hasController('user_role', 'storage') && $this->user->hasPermission('view the administration theme') && path_is_admin($path)); + return ($this->entityManager->getDefinition('user_role') && $this->user->hasPermission('view the administration theme') && path_is_admin($path)); } /** diff --git a/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php b/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php index 74897b3..c9f3ff3 100644 --- a/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php +++ b/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php @@ -49,16 +49,20 @@ public function testConstructor() { ->will($this->returnValue('node')); $actions[] = $action; - $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $storage_controller = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface'); $storage_controller->expects($this->any()) ->method('loadMultiple') ->will($this->returnValue($actions)); + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->once()) + ->method('getStorage') + ->will($this->returnValue($storage_controller)); + $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $entity_manager->expects($this->any()) - ->method('getStorageController') - ->with('action') - ->will($this->returnValue($storage_controller)); + ->method('getDefinition') + ->with($this->equalTo('action')) + ->will($this->returnValue($entity_type)); $user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', array(), $entity_manager); diff --git a/core/modules/user/tests/Drupal/user/Tests/Views/Argument/RolesRidTest.php b/core/modules/user/tests/Drupal/user/Tests/Views/Argument/RolesRidTest.php index 054d25a..1057961 100644 --- a/core/modules/user/tests/Drupal/user/Tests/Views/Argument/RolesRidTest.php +++ b/core/modules/user/tests/Drupal/user/Tests/Views/Argument/RolesRidTest.php @@ -58,6 +58,9 @@ public function testTitleQuery() { ->method('getKey') ->with('label') ->will($this->returnValue('label')); + $entity_type->expects($this->once()) + ->method('getStorage') + ->will($this->returnValue($role_storage_controller)); $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $entity_manager->expects($this->any()) @@ -65,12 +68,6 @@ public function testTitleQuery() { ->with($this->equalTo('user_role')) ->will($this->returnValue($entity_type)); - $entity_manager - ->expects($this->once()) - ->method('getStorageController') - ->with($this->equalTo('user_role')) - ->will($this->returnValue($role_storage_controller)); - // @todo \Drupal\Core\Entity\Entity::entityInfo() uses a global call to // entity_get_info(), which in turn wraps \Drupal::entityManager(). Set // the entity manager until this is fixed. diff --git a/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php b/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php index 307d63f..042ef49 100644 --- a/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php +++ b/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php @@ -56,7 +56,7 @@ public function __construct(EntityStorageControllerInterface $storage_controller */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('view'), + $container->get('entity.manager')->getDefinition('view')->getStorage(), $container->get('views.executable') ); } diff --git a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php index 9540364..54e010f 100644 --- a/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php +++ b/core/modules/views/lib/Drupal/views/EventSubscriber/RouteSubscriber.php @@ -69,7 +69,7 @@ class RouteSubscriber extends RouteSubscriberBase { * The state key value store. */ public function __construct(EntityManagerInterface $entity_manager, StateInterface $state) { - $this->viewStorageController = $entity_manager->getStorageController('view'); + $this->viewStorageController = $entity_manager->getDefinition('view')->getStorage(); $this->state = $state; } diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php index 56f3c86..0ac4088 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlockBase.php @@ -83,7 +83,7 @@ public static function create(ContainerInterface $container, array $configuratio return new static( $configuration, $plugin_id, $plugin_definition, $container->get('views.executable'), - $container->get('entity.manager')->getStorageController('view'), + $container->get('entity.manager')->getDefinition('view')->getStorage(), $container->get('current_user') ); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php index 30d242a..55887e6 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsBlock.php @@ -45,7 +45,7 @@ class ViewsBlock implements ContainerDerivativeInterface { public static function create(ContainerInterface $container, $base_plugin_id) { return new static( $base_plugin_id, - $container->get('entity.manager')->getStorageController('view') + $container->get('entity.manager')->getDefinition('view')->getStorage() ); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php index 5058364..7ece7e8 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsEntityRow.php @@ -93,7 +93,7 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin public function getDerivativeDefinitions(array $base_plugin_definition) { foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { // Just add support for entity types which have a views integration. - if (($base_table = $entity_info->getBaseTable()) && $this->viewsData->get($base_table) && $this->entityManager->hasController($entity_type, 'view_builder')) { + if (($base_table = $entity_info->getBaseTable()) && $this->viewsData->get($base_table) && $entity_info->hasController('view_builder')) { $this->derivatives[$entity_type] = array( 'id' => 'entity:' . $entity_type, 'provider' => 'views', diff --git a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php index 96bdd4c..bab1866 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Derivative/ViewsExposedFilterBlock.php @@ -58,7 +58,7 @@ public function __construct($base_plugin_id, EntityStorageControllerInterface $v public static function create(ContainerInterface $container, $base_plugin_id) { return new static( $base_plugin_id, - $container->get('entity.manager')->getStorageController('view') + $container->get('entity.manager')->getDefinition('view')->getStorage() ); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php b/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php index 6fcf820..d77b977 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/area/View.php @@ -56,10 +56,10 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('entity.manager')->getStorageController('view') + $configuration, + $plugin_id, + $plugin_definition, + $container->get('entity.manager')->getDefinition('view')->getStorage() ); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument_validator/Entity.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument_validator/Entity.php index 1d1d958..2f1cda5 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument_validator/Entity.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument_validator/Entity.php @@ -174,7 +174,7 @@ public function validateArgument($argument) { return FALSE; } - $entities = $this->entityManager->getStorageController($entity_type)->loadMultiple($ids); + $entities = $this->entityManager->getDefinition($entity_type)->getStorage()->loadMultiple($ids); // Validate each id => entity. If any fails break out and return false. foreach ($ids as $id) { // There is no entity for this ID. diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/field/Date.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/Date.php index 7ae6005..76e60e2 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/field/Date.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/Date.php @@ -65,7 +65,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $container->get('date'), - $container->get('entity.manager')->getStorageController('date_format') + $container->get('entity.manager')->getDefinition('date_format')->getStorage() ); } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/field/EntityLabel.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/EntityLabel.php index 7ac209b..b96efac 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/field/EntityLabel.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/EntityLabel.php @@ -130,8 +130,9 @@ public function preRender(&$values) { } } + $storage = $this->entityManager->getDefinition($type)->getStorage(); foreach ($entity_ids_per_type as $type => $ids) { - $this->loadedReferencers[$type] = $this->entityManager->getStorageController($type)->loadMultiple($ids); + $this->loadedReferencers[$type] = $storage->loadMultiple($ids); } } diff --git a/core/modules/views/lib/Drupal/views/Routing/ViewPageController.php b/core/modules/views/lib/Drupal/views/Routing/ViewPageController.php index ba0b10b..f191753 100644 --- a/core/modules/views/lib/Drupal/views/Routing/ViewPageController.php +++ b/core/modules/views/lib/Drupal/views/Routing/ViewPageController.php @@ -52,7 +52,7 @@ public function __construct(EntityStorageControllerInterface $storage_controller */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager')->getStorageController('view'), + $container->get('entity.manager')->getDefinition('view')->getStorage(), $container->get('views.executable') ); } diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php index 31be4ab..a5d5ada 100644 --- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php @@ -126,7 +126,7 @@ protected function setUp() { */ public function testDefaultViews() { // Get all default views. - $controller = $this->container->get('entity.manager')->getStorageController('view'); + $controller = \Drupal::entityManager()->getDefinition('view')->getStorage(); $views = $controller->loadMultiple(); foreach ($views as $name => $view_storage) { diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php index 528bcda..c6d993c 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/AreaEntityTest.php @@ -83,7 +83,7 @@ public function testEntityArea() { for ($i = 0; $i < 3; $i++) { $random_label = $this->randomName(); $data = array('bundle' => 'entity_test', 'name' => $random_label); - $entity_test = $this->container->get('entity.manager')->getStorageController('entity_test')->create($data); + $entity_test = \Drupal::entityManager()->getDefinition('entity_test')->getStorage()->create($data); $entity_test->save(); $entities[] = $entity_test; \Drupal::state()->set('entity_test_entity_access.view.' . $entity_test->id(), $i != 2); diff --git a/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php b/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php index 8c31874..f113645 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ModuleTest.php @@ -151,7 +151,7 @@ public function customErrorHandler($error_level, $message, $filename, $line, $co */ public function testLoadFunctions() { $this->enableModules(array('node')); - $controller = $this->container->get('entity.manager')->getStorageController('view'); + $controller = \Drupal::entityManager()->getDefinition('view')->getStorage(); // Test views_view_is_enabled/disabled. $archive = $controller->load('archive'); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTagTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTagTest.php index c183e57..e6ea66a 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTagTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/CacheTagTest.php @@ -86,9 +86,10 @@ protected function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); - $this->nodeStorageController = $this->container->get('entity.manager')->getStorageController('node'); - $this->nodeViewBuilder = $this->container->get('entity.manager')->getViewBuilder('node'); - $this->userViewBuilder = $this->container->get('entity.manager')->getViewBuilder('user'); + $definition = \Drupal::entityManager()->getDefinition('node'); + $this->nodeStorageController = $definition->getStorage(); + $this->nodeViewBuilder = $definition->getViewBuilder(); + $this->userViewBuilder = \Drupal::entityManager()->getDefinition('user')->getViewBuilder(); for ($i = 1; $i <= 5; $i++) { $this->pages[] = $this->drupalCreateNode(array('title' => "Test $i", 'type' => 'page')); diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayFeedTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayFeedTest.php index 408b243..a6dc8f4 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayFeedTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayFeedTest.php @@ -92,7 +92,7 @@ public function testFeedOutput() { $result = $this->xpath('//title'); $this->assertEqual($result[0], $site_name, 'The site title is used for the feed title.'); - $view = $this->container->get('entity.manager')->getStorageController('view')->load('test_feed_display'); + $view = \Drupal::entityManager()->getDefinition('view')->getStorage()->load('test_feed_display'); $display = &$view->getDisplay('feed_1'); $display['display_options']['sitename_title'] = 0; $view->save(); diff --git a/core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php b/core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php index 4ce4bac..83702fd 100644 --- a/core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php @@ -49,7 +49,7 @@ protected function setUp() { $this->installSchema('entity_test', array('entity_test')); - $this->storageController = $this->container->get('entity.manager')->getStorageController('entity_test'); + $this->storageController = \Drupal::entityManager()->getDefinition('entity_test')->getStorage(); } diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php index 9ac028e..1dce61f 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php @@ -250,7 +250,7 @@ public function testDisplays() { $this->assertTrue($view->rowPlugin instanceof Fields); // Test the newDisplay() method. - $view = $this->container->get('entity.manager')->getStorageController('view')->create(array('id' => 'test_executable_displays')); + $view = \Drupal::entityManager()->getDefinition('view')->getStorage()->create(array('id' => 'test_executable_displays')); $executable = $view->getExecutable(); $executable->newDisplay('page'); diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php index 4fc2f5c..c7a8c02 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewStorageTest.php @@ -74,7 +74,7 @@ public static function getInfo() { function testConfigurationEntityCRUD() { // Get the configuration entity information and controller. $this->info = \Drupal::entityManager()->getDefinition('view'); - $this->controller = $this->container->get('entity.manager')->getStorageController('view'); + $this->controller = $this->info->getStorage(); // Confirm that an info array has been returned. $this->assertTrue($this->info instanceof EntityTypeInterface, 'The View info array is loaded.'); diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewTestData.php b/core/modules/views/lib/Drupal/views/Tests/ViewTestData.php index 1117bd8..370e242 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewTestData.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewTestData.php @@ -36,7 +36,7 @@ public static function createTestViews($class, array $modules) { $class = get_parent_class($class); } if (!empty($views)) { - $storage_controller = \Drupal::entityManager()->getStorageController('view'); + $storage_controller = \Drupal::entityManager()->getDefinition('view')->getStorage(); $module_handler = \Drupal::moduleHandler(); foreach ($modules as $module) { $config_dir = drupal_get_path('module', $module) . '/test_views'; diff --git a/core/modules/views/lib/Drupal/views/Views.php b/core/modules/views/lib/Drupal/views/Views.php index ba45e17..cd4d880 100644 --- a/core/modules/views/lib/Drupal/views/Views.php +++ b/core/modules/views/lib/Drupal/views/Views.php @@ -86,7 +86,7 @@ public static function handlerManager($type) { * A view executable instance, from the loaded entity. */ public static function getView($id) { - $view = \Drupal::service('entity.manager')->getStorageController('view')->load($id); + $view = \Drupal::entityManager()->getDefinition('view')->getStorage()->load($id); if ($view) { return static::executableFactory()->get($view); } @@ -185,7 +185,7 @@ public static function getApplicableViews($type) { ->execute(); $result = array(); - foreach (\Drupal::entityManager()->getStorageController('view')->loadMultiple($entity_ids) as $view) { + foreach (\Drupal::entityManager()->getDefinition('view')->getStorage()->loadMultiple($entity_ids) as $view) { // Check each display to see if it meets the criteria and is enabled. $executable = $view->getExecutable(); $executable->initDisplay(); @@ -206,7 +206,7 @@ public static function getApplicableViews($type) { * An array of loaded view entities. */ public static function getAllViews() { - return \Drupal::entityManager()->getStorageController('view')->loadMultiple(); + return \Drupal::entityManager()->getDefinition('view')->getStorage()->loadMultiple(); } /** @@ -220,7 +220,7 @@ public static function getEnabledViews() { ->condition('status', TRUE) ->execute(); - return \Drupal::entityManager()->getStorageController('view')->loadMultiple($query); + return \Drupal::entityManager()->getDefinition('view')->getStorage()->loadMultiple($query); } /** @@ -234,7 +234,7 @@ public static function getDisabledViews() { ->condition('status', FALSE) ->execute(); - return \Drupal::entityManager()->getStorageController('view')->loadMultiple($query); + return \Drupal::entityManager()->getDefinition('view')->getStorage()->loadMultiple($query); } /** diff --git a/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php b/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php index e5d6c69..b060c7c 100644 --- a/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/EventSubscriber/RouteSubscriberTest.php @@ -60,14 +60,19 @@ public static function getInfo() { } protected function setUp() { - $this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $this->viewStorageController = $this->getMockBuilder('\Drupal\views\ViewStorageController') ->disableOriginalConstructor() ->getMock(); - $this->entityManager->expects($this->any()) - ->method('getStorageController') - ->with('view') + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->any()) + ->method('getStorage') ->will($this->returnValue($this->viewStorageController)); + + $this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); + $this->entityManager->expects($this->any()) + ->method('getDefinition') + ->with($this->equalTo('view')) + ->will($this->returnValue($entity_type)); $this->state = $this->getMock('\Drupal\Core\KeyValueStore\StateInterface'); $this->routeSubscriber = new TestRouteSubscriber($this->entityManager, $this->state); } diff --git a/core/modules/views/tests/Drupal/views/Tests/Plugin/argument_validator/EntityTest.php b/core/modules/views/tests/Drupal/views/Tests/Plugin/argument_validator/EntityTest.php index c6a9104..4e1c2c3 100644 --- a/core/modules/views/tests/Drupal/views/Tests/Plugin/argument_validator/EntityTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/Plugin/argument_validator/EntityTest.php @@ -109,10 +109,17 @@ protected function setUp() { ->method('loadMultiple') ->will($this->returnValueMap($value_map)); - $this->entityManager->expects($this->any()) - ->method('getStorageController') + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->any()) + ->method('getStorage') ->will($this->returnValue($storage_controller)); + $this->entityManager->expects($this->any()) + ->method('getDefinition') + ->with($this->equalTo('entity_test')) + ->will($this->returnValue($entity_type)); + + $this->executable = $this->getMockBuilder('Drupal\views\ViewExecutable') ->disableOriginalConstructor() ->getMock(); diff --git a/core/modules/views/tests/Drupal/views/Tests/ViewsTest.php b/core/modules/views/tests/Drupal/views/Tests/ViewsTest.php index 9466c0b..f04b7d2 100644 --- a/core/modules/views/tests/Drupal/views/Tests/ViewsTest.php +++ b/core/modules/views/tests/Drupal/views/Tests/ViewsTest.php @@ -43,11 +43,15 @@ protected function setUp() { ->with('test_view') ->will($this->returnValue($this->view)); + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->once()) + ->method('getStorage') + ->will($this->returnValue($view_storage_controller)); $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $entity_manager->expects($this->once()) - ->method('getStorageController') - ->with('view') - ->will($this->returnValue($view_storage_controller)); + ->method('getDefinition') + ->with($this->equalTo('view')) + ->will($this->returnValue($entity_type)); $container->set('entity.manager', $entity_manager); \Drupal::setContainer($container); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php b/core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php index 90c1d58..5df6fbf 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Controller/ViewsUIController.php @@ -91,7 +91,7 @@ public static function create(ContainerInterface $container) { * The Views fields report page. */ public function reportFields() { - $views = $this->entityManager->getStorageController('view')->loadMultiple(); + $views = $this->entityManager->getDefinition('view')->getStorage()->loadMultiple(); // Fetch all fieldapi fields which are used in views // Therefore search in all views, displays and handler-types. @@ -187,7 +187,7 @@ public function ajaxOperation(ViewStorageInterface $view, $op, Request $request) // If the request is via AJAX, return the rendered list as JSON. if ($request->request->get('js')) { - $list = $this->entityManager->getListController('view')->render(); + $list = $this->entityManager->getDefinition('view')->getList()->render(); $response = new AjaxResponse(); $response->addCommand(new ReplaceCommand('#views-entity-list', drupal_render($list))); return $response; @@ -210,7 +210,7 @@ public function autocompleteTag(Request $request) { $matches = array(); $string = $request->query->get('q'); // Get matches from default views. - $views = $this->entityManager->getStorageController('view')->loadMultiple(); + $views = $this->entityManager->getDefinition('view')->getStorage()->loadMultiple(); foreach ($views as $view) { $tag = $view->get('tag'); if ($tag && strpos($tag, $string) === 0) { diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php index cfb0a8b..12aad33 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/ViewsFormBase.php @@ -168,7 +168,7 @@ public function getForm(ViewStorageInterface $view, $display_id, $js) { // If this form was for view-wide changes, there's no need to regenerate // the display section of the form. if ($display_id !== '') { - \Drupal::entityManager()->getFormController('view', 'edit')->rebuildCurrentTab($view, $response, $display_id); + \Drupal::entityManager()->getDefinition('view')->getForm('edit')->rebuildCurrentTab($view, $response, $display_id); } return $response; diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php index 8d0b48d..ffa3128 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php @@ -73,7 +73,7 @@ public function getQuestion() { */ public function getDescription() { $locked = $this->tempStore->getMetadata($this->entity->id()); - $account = $this->entityManager->getStorageController('user')->load($locked->owner); + $account = $this->entityManager->getDefinition('user')->getStorage()->load($locked->owner); $username = array( '#theme' => 'username', '#account' => $account, diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/GroupByTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/GroupByTest.php index cffcfc3..1be9a60 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/GroupByTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/GroupByTest.php @@ -52,7 +52,7 @@ function testGroupBySave() { $this->drupalPostForm(NULL, array(), t('Save')); - $view = $this->container->get('entity.manager')->getStorageController('view')->load('test_views_groupby_save'); + $view = \Drupal::entityManager()->getDefinition('view')->getStorage()->load('test_views_groupby_save'); $display = $view->getDisplay('default'); $this->assertTrue($display['display_options']['group_by'], 'The groupby setting was saved on the view.'); $this->assertEqual($display['display_options']['fields']['id']['group_type'], 'count', 'Count groupby_type was saved on the view.'); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/HandlerTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/HandlerTest.php index 7ff3747..9a2f354 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/HandlerTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/HandlerTest.php @@ -75,6 +75,7 @@ protected function viewsData() { * Tests UI CRUD. */ public function testUICRUD() { + $storage = \Drupal::entityManager()->getDefinition('view')->getStorage(); $handler_types = ViewExecutable::viewsHandlerTypes(); foreach ($handler_types as $type => $type_info) { // Test adding handlers. @@ -109,7 +110,7 @@ public function testUICRUD() { // Save the view and have a look whether the handler was added as expected. $this->drupalPostForm(NULL, array(), t('Save')); - $view = $this->container->get('entity.manager')->getStorageController('view')->load('test_view_empty'); + $view = $storage->load('test_view_empty'); $display = $view->getDisplay('default'); $this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.'); @@ -118,7 +119,7 @@ public function testUICRUD() { $this->assertNoLinkByHref($edit_handler_url, 0, 'The handler edit link does not appears in the UI after removing.'); $this->drupalPostForm(NULL, array(), t('Save')); - $view = $this->container->get('entity.manager')->getStorageController('view')->load('test_view_empty'); + $view = $storage->load('test_view_empty'); $display = $view->getDisplay('default'); $this->assertFalse(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was removed from the view itself.'); } @@ -139,7 +140,7 @@ public function testUICRUD() { $this->drupalPostForm(NULL, array(), t('Apply')); $this->drupalPostForm(NULL, array(), t('Save')); - $view = $this->container->get('entity.manager')->getStorageController('view')->load('test_view_empty'); + $view = $storage->load('test_view_empty'); $display = $view->getDisplay('default'); $this->assertTrue(isset($display['display_options'][$type_info['plural']][$id]), 'Ensure the field was added to the view itself.'); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewEditTest.php b/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewEditTest.php index 27655a8..3903deb 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewEditTest.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Tests/ViewEditTest.php @@ -41,7 +41,7 @@ public function testDeleteLink() { $this->drupalPostForm(NULL, array(), t('Delete')); $this->assertUrl('admin/structure/views'); - $view = $this->container->get('entity.manager')->getStorageController('view')->load('test_view'); + $view = \Drupal::entityManager()->getDefinition('view')->getStorage()->load('test_view'); $this->assertFalse($view instanceof View); } 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..91e191d 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewListController.php @@ -12,9 +12,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Config\Entity\ConfigEntityListController; 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 +32,21 @@ 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('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\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, PluginManagerInterface $display_manager) { + parent::__construct($entity_info); $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..c17ff46 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 @@ -28,9 +28,6 @@ public static function getInfo() { * @see \Drupal\views_ui\ViewListController::getDisplaysList(). */ public function testBuildRowEntityList() { - $storage_controller = $this->getMockBuilder('Drupal\views\ViewStorageController') - ->disableOriginalConstructor() - ->getMock(); $display_manager = $this->getMockBuilder('\Drupal\views\Plugin\ViewsPluginManager') ->disableOriginalConstructor() ->getMock(); @@ -125,7 +122,7 @@ public function testBuildRowEntityList() { // 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, $display_manager, $module_handler)); $view_list_controller->expects($this->any()) ->method('buildOperations') ->will($this->returnValue(array())); diff --git a/core/tests/Drupal/Tests/Core/Datetime/DateTest.php b/core/tests/Drupal/Tests/Core/Datetime/DateTest.php index 32d2103..52d3907 100644 --- a/core/tests/Drupal/Tests/Core/Datetime/DateTest.php +++ b/core/tests/Drupal/Tests/Core/Datetime/DateTest.php @@ -59,7 +59,16 @@ public static function getInfo() { } protected function setUp() { + $storage_controller = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface'); + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->any()) + ->method('getStorage') + ->will($this->returnValue($storage_controller)); $this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); + $this->entityManager->expects($this->any()) + ->method('getDefinition') + ->with($this->equalTo('date_format')) + ->will($this->returnValue($entity_type)); $this->languageManager = $this->getMockBuilder('Drupal\Core\Language\LanguageManager') ->disableOriginalConstructor() ->getMock(); diff --git a/core/tests/Drupal/Tests/Core/Entity/Controller/EntityViewControllerTest.php b/core/tests/Drupal/Tests/Core/Entity/Controller/EntityViewControllerTest.php index f329135..1d7b638 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Controller/EntityViewControllerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Controller/EntityViewControllerTest.php @@ -40,11 +40,15 @@ public function testView() { ->method('view') ->will($this->returnValue('Output from rendering the entity')); + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->any()) + ->method('getViewBuilder') + ->will($this->returnValue($render_controller)); // Mock an entity manager. $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $entity_manager->expects($this->any()) - ->method('getViewBuilder') - ->will($this->returnValue($render_controller)); + ->method('getDefinition') + ->will($this->returnValue($entity_type)); // Mock an 'entity_test' entity. $entity = $this->getMockBuilder('Drupal\entity_test\Entity\EntityTest') diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php index fdf5675..4318ad8 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityCreateAccessCheckTest.php @@ -81,9 +81,14 @@ public function testAccess($entity_bundle, $requirement, $access, $expected) { ->with($entity_bundle) ->will($this->returnValue($access)); - $entity_manager->expects($this->any()) - ->method('getAccessController') + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->once()) + ->method('getAccess') ->will($this->returnValue($access_controller)); + + $entity_manager->expects($this->any()) + ->method('getDefinition') + ->will($this->returnValue($entity_type)); } $applies_check = new EntityCreateAccessCheck($entity_manager); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php index 6db04b5..8c3f715 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php @@ -49,10 +49,9 @@ protected function setUp() { parent::setUp(); $this->role = $this->getMock('Drupal\user\RoleInterface'); - $role_storage_controller = $this->getMock('Drupal\user\RoleStorageControllerInterface'); $module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); - $this->entityListController = new TestEntityListController($entity_type, $role_storage_controller, $module_handler); + $this->entityListController = new TestEntityListController($entity_type, $module_handler); } /** diff --git a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php index 8309852..4fc89b7 100644 --- a/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php +++ b/core/tests/Drupal/Tests/Core/Session/UserSessionTest.php @@ -105,11 +105,17 @@ protected function setUp() { array(array('role_one', 'role_two'), array($roles['role_one'], $roles['role_two'])), ))); + $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); + $entity_type->expects($this->any()) + ->method('getStorage') + ->will($this->returnValue($role_storage)); + $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $entity_manager->expects($this->any()) - ->method('getStorageController') + ->method('getDefinition') ->with($this->equalTo('user_role')) - ->will($this->returnValue($role_storage)); + ->will($this->returnValue($entity_type)); + $container = new ContainerBuilder(); $container->set('entity.manager', $entity_manager); \Drupal::setContainer($container);