Commit 2f959b96 authored by catch's avatar catch

Issue #2188613 by Berdir, Xen, andypost: Rename EntityStorageController to EntityStorage.

parent 2421c75f
...@@ -69,11 +69,11 @@ function entity_get_bundles($entity_type = NULL) { ...@@ -69,11 +69,11 @@ function entity_get_bundles($entity_type = NULL) {
function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = NULL) { function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = NULL) {
entity_info_cache_clear(); entity_info_cache_clear();
// Notify the entity storage controller. // Notify the entity storage.
$method = 'onBundle' . ucfirst($hook); $method = 'onBundle' . ucfirst($hook);
$storage_controller = \Drupal::entityManager()->getStorageController($entity_type); $storage = \Drupal::entityManager()->getStorage($entity_type);
if (method_exists($storage_controller, $method)) { if (method_exists($storage, $method)) {
$storage_controller->$method($bundle, $bundle_new); $storage->$method($bundle, $bundle_new);
} }
// Invoke hook_entity_bundle_*() hooks. // Invoke hook_entity_bundle_*() hooks.
\Drupal::moduleHandler()->invokeAll('entity_bundle_' . $hook, array($entity_type, $bundle, $bundle_new)); \Drupal::moduleHandler()->invokeAll('entity_bundle_' . $hook, array($entity_type, $bundle, $bundle_new));
...@@ -137,12 +137,12 @@ function entity_get_view_modes($entity_type_id = NULL) { ...@@ -137,12 +137,12 @@ function entity_get_view_modes($entity_type_id = NULL) {
* The entity object, or NULL if there is no entity with the given id. * The entity object, or NULL if there is no entity with the given id.
* *
* @see \Drupal\Core\Entity\EntityManagerInterface * @see \Drupal\Core\Entity\EntityManagerInterface
* @see \Drupal\Core\Entity\EntityStorageControllerInterface * @see \Drupal\Core\Entity\EntityStorageInterface
* @see \Drupal\Core\Entity\DatabaseStorageController * @see \Drupal\Core\Entity\ContentEntityDatabaseStorage
* @see \Drupal\Core\Entity\Query\QueryInterface * @see \Drupal\Core\Entity\Query\QueryInterface
*/ */
function entity_load($entity_type, $id, $reset = FALSE) { function entity_load($entity_type, $id, $reset = FALSE) {
$controller = \Drupal::entityManager()->getStorageController($entity_type); $controller = \Drupal::entityManager()->getStorage($entity_type);
if ($reset) { if ($reset) {
$controller->resetCache(array($id)); $controller->resetCache(array($id));
} }
...@@ -162,12 +162,12 @@ function entity_load($entity_type, $id, $reset = FALSE) { ...@@ -162,12 +162,12 @@ function entity_load($entity_type, $id, $reset = FALSE) {
* id. * id.
* *
* @see \Drupal\Core\Entity\EntityManagerInterface * @see \Drupal\Core\Entity\EntityManagerInterface
* @see \Drupal\Core\Entity\EntityStorageControllerInterface * @see \Drupal\Core\Entity\EntityStorageInterface
* @see \Drupal\Core\Entity\DatabaseStorageController * @see \Drupal\Core\Entity\ContentEntityDatabaseStorage
*/ */
function entity_revision_load($entity_type, $revision_id) { function entity_revision_load($entity_type, $revision_id) {
return \Drupal::entityManager() return \Drupal::entityManager()
->getStorageController($entity_type) ->getStorage($entity_type)
->loadRevision($revision_id); ->loadRevision($revision_id);
} }
...@@ -181,7 +181,7 @@ function entity_revision_load($entity_type, $revision_id) { ...@@ -181,7 +181,7 @@ function entity_revision_load($entity_type, $revision_id) {
*/ */
function entity_revision_delete($entity_type, $revision_id) { function entity_revision_delete($entity_type, $revision_id) {
\Drupal::entityManager() \Drupal::entityManager()
->getStorageController($entity_type) ->getStorage($entity_type)
->deleteRevision($revision_id); ->deleteRevision($revision_id);
} }
...@@ -212,7 +212,7 @@ function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) { ...@@ -212,7 +212,7 @@ function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) {
throw new EntityStorageException("Entity type $entity_type_id does not support UUIDs."); throw new EntityStorageException("Entity type $entity_type_id does not support UUIDs.");
} }
$controller = \Drupal::entityManager()->getStorageController($entity_type_id); $controller = \Drupal::entityManager()->getStorage($entity_type_id);
if ($reset) { if ($reset) {
$controller->resetCache(); $controller->resetCache();
} }
...@@ -228,14 +228,15 @@ function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) { ...@@ -228,14 +228,15 @@ function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) {
* database access if loaded again during the same page request. * database access if loaded again during the same page request.
* *
* The actual loading is done through a class that has to implement the * The actual loading is done through a class that has to implement the
* Drupal\Core\Entity\EntityStorageControllerInterface interface. By default, * Drupal\Core\Entity\EntityStorageInterface interface. By default,
* Drupal\Core\Entity\DatabaseStorageController is used. Entity types can * Drupal\Core\Entity\ContentEntityDatabaseStorage is used for content entities
* specify that a different class should be used by setting the * and Drupal\Core\Config\Entity\ConfigEntityStorage for config entities. Entity
* types can specify that a different class should be used by setting the
* "controllers['storage']" key in the entity plugin annotation. These classes * "controllers['storage']" key in the entity plugin annotation. These classes
* can either implement the Drupal\Core\Entity\EntityStorageControllerInterface * can either implement the Drupal\Core\Entity\EntityStorageInterface
* interface, or, most commonly, extend the * interface, or, most commonly, extend the
* Drupal\Core\Entity\DatabaseStorageController class. * Drupal\Core\Entity\ContentEntityDatabaseStorage class.
* See Drupal\node\Entity\Node and Drupal\node\NodeStorageController * See Drupal\node\Entity\Node and Drupal\node\NodeStorage
* for an example. * for an example.
* *
* @param string $entity_type * @param string $entity_type
...@@ -249,12 +250,12 @@ function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) { ...@@ -249,12 +250,12 @@ function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) {
* An array of entity objects indexed by their ids. * An array of entity objects indexed by their ids.
* *
* @see \Drupal\Core\Entity\EntityManagerInterface * @see \Drupal\Core\Entity\EntityManagerInterface
* @see \Drupal\Core\Entity\EntityStorageControllerInterface * @see \Drupal\Core\Entity\EntityStorageInterface
* @see \Drupal\Core\Entity\DatabaseStorageController * @see \Drupal\Core\Entity\ContentEntityDatabaseStorage
* @see \Drupal\Core\Entity\Query\QueryInterface * @see \Drupal\Core\Entity\Query\QueryInterface
*/ */
function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
$controller = \Drupal::entityManager()->getStorageController($entity_type); $controller = \Drupal::entityManager()->getStorage($entity_type);
if ($reset) { if ($reset) {
$controller->resetCache($ids); $controller->resetCache($ids);
} }
...@@ -275,7 +276,7 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) { ...@@ -275,7 +276,7 @@ function entity_load_multiple($entity_type, array $ids = NULL, $reset = FALSE) {
*/ */
function entity_load_multiple_by_properties($entity_type, array $values) { function entity_load_multiple_by_properties($entity_type, array $values) {
return \Drupal::entityManager() return \Drupal::entityManager()
->getStorageController($entity_type) ->getStorage($entity_type)
->loadByProperties($values); ->loadByProperties($values);
} }
...@@ -297,7 +298,7 @@ function entity_load_multiple_by_properties($entity_type, array $values) { ...@@ -297,7 +298,7 @@ function entity_load_multiple_by_properties($entity_type, array $values) {
*/ */
function entity_load_unchanged($entity_type, $id) { function entity_load_unchanged($entity_type, $id) {
return \Drupal::entityManager() return \Drupal::entityManager()
->getStorageController($entity_type) ->getStorage($entity_type)
->loadUnchanged($id); ->loadUnchanged($id);
} }
...@@ -310,7 +311,7 @@ function entity_load_unchanged($entity_type, $id) { ...@@ -310,7 +311,7 @@ function entity_load_unchanged($entity_type, $id) {
* An array of entity IDs of the entities to delete. * An array of entity IDs of the entities to delete.
*/ */
function entity_delete_multiple($entity_type, array $ids) { function entity_delete_multiple($entity_type, array $ids) {
$controller = \Drupal::entityManager()->getStorageController($entity_type); $controller = \Drupal::entityManager()->getStorage($entity_type);
$entities = $controller->loadMultiple($ids); $entities = $controller->loadMultiple($ids);
$controller->delete($entities); $controller->delete($entities);
} }
...@@ -329,23 +330,23 @@ function entity_delete_multiple($entity_type, array $ids) { ...@@ -329,23 +330,23 @@ function entity_delete_multiple($entity_type, array $ids) {
*/ */
function entity_create($entity_type, array $values = array()) { function entity_create($entity_type, array $values = array()) {
return \Drupal::entityManager() return \Drupal::entityManager()
->getStorageController($entity_type) ->getStorage($entity_type)
->create($values); ->create($values);
} }
/** /**
* Gets the entity controller class for an entity type. * Gets the entity controller class for an entity type.
* *
* @return \Drupal\Core\Entity\EntityStorageControllerInterface * @return \Drupal\Core\Entity\EntityStorageInterface
* *
* @see \Drupal\Core\Entity\EntityManagerInterface::getStorageController(). * @see \Drupal\Core\Entity\EntityManagerInterface::getStorage()
* *
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
* Use \Drupal::entityManager()->getStorageController(). * Use \Drupal::entityManager()->getStorage().
*/ */
function entity_get_controller($entity_type) { function entity_get_controller($entity_type) {
return \Drupal::entityManager() return \Drupal::entityManager()
->getStorageController($entity_type); ->getStorage($entity_type);
} }
/** /**
......
...@@ -211,7 +211,7 @@ ...@@ -211,7 +211,7 @@
/** /**
* The maximum depth of a menu links tree - matches the number of p columns. * The maximum depth of a menu links tree - matches the number of p columns.
* *
* @todo Move this constant to MenuLinkStorageController along with all the tree * @todo Move this constant to MenuLinkStorage along with all the tree
* functionality. * functionality.
*/ */
const MENU_MAX_DEPTH = 9; const MENU_MAX_DEPTH = 9;
...@@ -964,7 +964,7 @@ function menu_cache_clear_all() { ...@@ -964,7 +964,7 @@ function menu_cache_clear_all() {
*/ */
function menu_reset_static_cache() { function menu_reset_static_cache() {
\Drupal::entityManager() \Drupal::entityManager()
->getStorageController('menu_link')->resetCache(); ->getStorage('menu_link')->resetCache();
drupal_static_reset('_menu_build_tree'); drupal_static_reset('_menu_build_tree');
drupal_static_reset('menu_tree'); drupal_static_reset('menu_tree');
drupal_static_reset('menu_tree_all_data'); drupal_static_reset('menu_tree_all_data');
...@@ -1028,9 +1028,9 @@ function menu_link_rebuild_defaults() { ...@@ -1028,9 +1028,9 @@ function menu_link_rebuild_defaults() {
// when possible. // when possible.
return; return;
} }
/** @var \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage */ /** @var \Drupal\menu_link\MenuLinkStorageInterface $menu_link_storage */
$menu_link_storage = \Drupal::entityManager() $menu_link_storage = \Drupal::entityManager()
->getStorageController('menu_link'); ->getStorage('menu_link');
$links = array(); $links = array();
$children = array(); $children = array();
$top_links = array(); $top_links = array();
......
...@@ -281,7 +281,7 @@ protected function importConfig($op, $name) { ...@@ -281,7 +281,7 @@ protected function importConfig($op, $name) {
} }
/** /**
* Invokes import* methods on configuration entity storage controllers. * Invokes import* methods on configuration entity storage.
* *
* Allow modules to take over configuration change operations for higher-level * Allow modules to take over configuration change operations for higher-level
* configuration data. * configuration data.
...@@ -318,9 +318,9 @@ protected function importInvokeOwner($op, $name) { ...@@ -318,9 +318,9 @@ protected function importInvokeOwner($op, $name) {
} }
$method = 'import' . ucfirst($op); $method = 'import' . ucfirst($op);
$entity_storage = $this->configManager->getEntityManager()->getStorageController($entity_type); $entity_storage = $this->configManager->getEntityManager()->getStorage($entity_type);
// Call to the configuration entity's storage controller to handle the // Call to the configuration entity's storage to handle the configuration
// configuration change. // change.
if (!($entity_storage instanceof ImportableEntityStorageInterface)) { if (!($entity_storage instanceof ImportableEntityStorageInterface)) {
throw new EntityStorageException(String::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type))); throw new EntityStorageException(String::format('The entity storage "@storage" for the "@entity_type" entity type does not support imports', array('@storage' => get_class($entity_storage), '@entity_type' => $entity_type)));
} }
......
...@@ -127,7 +127,7 @@ public function installDefaultConfig($type, $name) { ...@@ -127,7 +127,7 @@ public function installDefaultConfig($type, $name) {
if ($entity_type = $this->configManager->getEntityTypeIdByName($name)) { if ($entity_type = $this->configManager->getEntityTypeIdByName($name)) {
$entity_storage = $this->configManager $entity_storage = $this->configManager
->getEntityManager() ->getEntityManager()
->getStorageController($entity_type); ->getStorage($entity_type);
// It is possible that secondary writes can occur during configuration // It is possible that secondary writes can occur during configuration
// creation. Updates of such configuration are allowed. // creation. Updates of such configuration are allowed.
if ($this->activeStorage->exists($name)) { if ($this->activeStorage->exists($name)) {
......
...@@ -188,7 +188,7 @@ public function findConfigEntityDependentsAsEntities($type, array $names) { ...@@ -188,7 +188,7 @@ public function findConfigEntityDependentsAsEntities($type, array $names) {
$definitions = $this->entityManager->getDefinitions(); $definitions = $this->entityManager->getDefinitions();
foreach ($dependencies as $config_name => $dependency) { foreach ($dependencies as $config_name => $dependency) {
// Group by entity type to efficient load entities using // Group by entity type to efficient load entities using
// \Drupal\Core\Entity\EntityStorageControllerInterface::loadMultiple(). // \Drupal\Core\Entity\EntityStorageInterface::loadMultiple().
$entity_type_id = $this->getEntityTypeIdByName($config_name); $entity_type_id = $this->getEntityTypeIdByName($config_name);
// It is possible that a non-configuration entity will be returned if a // It is possible that a non-configuration entity will be returned if a
// simple configuration object has a UUID key. This would occur if the // simple configuration object has a UUID key. This would occur if the
...@@ -201,10 +201,10 @@ public function findConfigEntityDependentsAsEntities($type, array $names) { ...@@ -201,10 +201,10 @@ public function findConfigEntityDependentsAsEntities($type, array $names) {
} }
$entities_to_return = array(); $entities_to_return = array();
foreach ($entities as $entity_type_id => $entities_to_load) { foreach ($entities as $entity_type_id => $entities_to_load) {
$storage_controller = $this->entityManager->getStorageController($entity_type_id); $storage = $this->entityManager->getStorage($entity_type_id);
// Remove the keys since there are potential ID clashes from different // Remove the keys since there are potential ID clashes from different
// configuration entity types. // configuration entity types.
$entities_to_return = array_merge($entities_to_return, array_values($storage_controller->loadMultiple($entities_to_load))); $entities_to_return = array_merge($entities_to_return, array_values($storage->loadMultiple($entities_to_load)));
} }
return $entities_to_return; return $entities_to_return;
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
use Drupal\Core\Database\Connection; use Drupal\Core\Database\Connection;
/** /**
* Defines the Database storage controller. * Defines the Database storage.
*/ */
class DatabaseStorage implements StorageInterface { class DatabaseStorage implements StorageInterface {
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
use Drupal\Component\Utility\String; use Drupal\Component\Utility\String;
use Drupal\Core\Entity\Entity; use Drupal\Core\Entity\Entity;
use Drupal\Core\Config\ConfigDuplicateUUIDException; use Drupal\Core\Config\ConfigDuplicateUUIDException;
use Drupal\Core\Entity\EntityStorageControllerInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Language\Language; use Drupal\Core\Language\Language;
/** /**
...@@ -256,8 +256,8 @@ public function toArray() { ...@@ -256,8 +256,8 @@ public function toArray() {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function preSave(EntityStorageControllerInterface $storage_controller) { public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage_controller); parent::preSave($storage);
// @todo When \Drupal\Core\Config\Entity\EntityWithPluginBagInterface moves // @todo When \Drupal\Core\Config\Entity\EntityWithPluginBagInterface moves
// to a trait, switch to class_uses() instead. // to a trait, switch to class_uses() instead.
...@@ -270,7 +270,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) { ...@@ -270,7 +270,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
// Ensure this entity's UUID does not exist with a different ID, regardless // Ensure this entity's UUID does not exist with a different ID, regardless
// of whether it's new or updated. // of whether it's new or updated.
$matching_entities = $storage_controller->getQuery() $matching_entities = $storage->getQuery()
->condition('uuid', $this->uuid()) ->condition('uuid', $this->uuid())
->execute(); ->execute();
$matched_entity = reset($matching_entities); $matched_entity = reset($matching_entities);
...@@ -279,7 +279,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) { ...@@ -279,7 +279,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
} }
if (!$this->isNew()) { if (!$this->isNew()) {
$original = $storage_controller->loadUnchanged($this->id()); $original = $storage->loadUnchanged($this->id());
// Ensure that the UUID cannot be changed for an existing entity. // Ensure that the UUID cannot be changed for an existing entity.
if ($original && ($original->uuid() != $this->uuid())) { if ($original && ($original->uuid() != $this->uuid())) {
throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid()))); throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid())));
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Definition of Drupal\Core\Config\Entity\ConfigStorageController. * Definition of Drupal\Core\Config\Entity\ConfigEntityStorage.
*/ */
namespace Drupal\Core\Config\Entity; namespace Drupal\Core\Config\Entity;
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityMalformedException; use Drupal\Core\Entity\EntityMalformedException;
use Drupal\Core\Entity\EntityStorageControllerBase; use Drupal\Core\Entity\EntityStorageBase;
use Drupal\Core\Config\Config; use Drupal\Core\Config\Config;
use Drupal\Core\Config\StorageInterface; use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeInterface;
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Defines the storage controller class for configuration entities. * Defines the storage class for configuration entities.
* *
* Configuration object names of configuration entities are comprised of two