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) {
function entity_invoke_bundle_hook($hook, $entity_type, $bundle, $bundle_new = NULL) {
entity_info_cache_clear();
// Notify the entity storage controller.
// Notify the entity storage.
$method = 'onBundle' . ucfirst($hook);
$storage_controller = \Drupal::entityManager()->getStorageController($entity_type);
if (method_exists($storage_controller, $method)) {
$storage_controller->$method($bundle, $bundle_new);
$storage = \Drupal::entityManager()->getStorage($entity_type);
if (method_exists($storage, $method)) {
$storage->$method($bundle, $bundle_new);
}
// Invoke hook_entity_bundle_*() hooks.
\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) {
* The entity object, or NULL if there is no entity with the given id.
*
* @see \Drupal\Core\Entity\EntityManagerInterface
* @see \Drupal\Core\Entity\EntityStorageControllerInterface
* @see \Drupal\Core\Entity\DatabaseStorageController
* @see \Drupal\Core\Entity\EntityStorageInterface
* @see \Drupal\Core\Entity\ContentEntityDatabaseStorage
* @see \Drupal\Core\Entity\Query\QueryInterface
*/
function entity_load($entity_type, $id, $reset = FALSE) {
$controller = \Drupal::entityManager()->getStorageController($entity_type);
$controller = \Drupal::entityManager()->getStorage($entity_type);
if ($reset) {
$controller->resetCache(array($id));
}
......@@ -162,12 +162,12 @@ function entity_load($entity_type, $id, $reset = FALSE) {
* id.
*
* @see \Drupal\Core\Entity\EntityManagerInterface
* @see \Drupal\Core\Entity\EntityStorageControllerInterface
* @see \Drupal\Core\Entity\DatabaseStorageController
* @see \Drupal\Core\Entity\EntityStorageInterface
* @see \Drupal\Core\Entity\ContentEntityDatabaseStorage
*/
function entity_revision_load($entity_type, $revision_id) {
return \Drupal::entityManager()
->getStorageController($entity_type)
->getStorage($entity_type)
->loadRevision($revision_id);
}
......@@ -181,7 +181,7 @@ function entity_revision_load($entity_type, $revision_id) {
*/
function entity_revision_delete($entity_type, $revision_id) {
\Drupal::entityManager()
->getStorageController($entity_type)
->getStorage($entity_type)
->deleteRevision($revision_id);
}
......@@ -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.");
}
$controller = \Drupal::entityManager()->getStorageController($entity_type_id);
$controller = \Drupal::entityManager()->getStorage($entity_type_id);
if ($reset) {
$controller->resetCache();
}
......@@ -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.
*
* The actual loading is done through a class that has to implement the
* Drupal\Core\Entity\EntityStorageControllerInterface interface. By default,
* Drupal\Core\Entity\DatabaseStorageController is used. Entity types can
* specify that a different class should be used by setting the
* Drupal\Core\Entity\EntityStorageInterface interface. By default,
* Drupal\Core\Entity\ContentEntityDatabaseStorage is used for content entities
* 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
* can either implement the Drupal\Core\Entity\EntityStorageControllerInterface
* can either implement the Drupal\Core\Entity\EntityStorageInterface
* interface, or, most commonly, extend the
* Drupal\Core\Entity\DatabaseStorageController class.
* See Drupal\node\Entity\Node and Drupal\node\NodeStorageController
* Drupal\Core\Entity\ContentEntityDatabaseStorage class.
* See Drupal\node\Entity\Node and Drupal\node\NodeStorage
* for an example.
*
* @param string $entity_type
......@@ -249,12 +250,12 @@ function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) {
* An array of entity objects indexed by their ids.
*
* @see \Drupal\Core\Entity\EntityManagerInterface
* @see \Drupal\Core\Entity\EntityStorageControllerInterface
* @see \Drupal\Core\Entity\DatabaseStorageController
* @see \Drupal\Core\Entity\EntityStorageInterface
* @see \Drupal\Core\Entity\ContentEntityDatabaseStorage
* @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()->getStorage($entity_type);
if ($reset) {
$controller->resetCache($ids);
}
......@@ -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) {
return \Drupal::entityManager()
->getStorageController($entity_type)
->getStorage($entity_type)
->loadByProperties($values);
}
......@@ -297,7 +298,7 @@ function entity_load_multiple_by_properties($entity_type, array $values) {
*/
function entity_load_unchanged($entity_type, $id) {
return \Drupal::entityManager()
->getStorageController($entity_type)
->getStorage($entity_type)
->loadUnchanged($id);
}
......@@ -310,7 +311,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()->getStorage($entity_type);
$entities = $controller->loadMultiple($ids);
$controller->delete($entities);
}
......@@ -329,23 +330,23 @@ function entity_delete_multiple($entity_type, array $ids) {
*/
function entity_create($entity_type, array $values = array()) {
return \Drupal::entityManager()
->getStorageController($entity_type)
->getStorage($entity_type)
->create($values);
}
/**
* 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.
* Use \Drupal::entityManager()->getStorageController().
* Use \Drupal::entityManager()->getStorage().
*/
function entity_get_controller($entity_type) {
return \Drupal::entityManager()
->getStorageController($entity_type);
->getStorage($entity_type);
}
/**
......
......@@ -211,7 +211,7 @@
/**
* 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.
*/
const MENU_MAX_DEPTH = 9;
......@@ -964,7 +964,7 @@ function menu_cache_clear_all() {
*/
function menu_reset_static_cache() {
\Drupal::entityManager()
->getStorageController('menu_link')->resetCache();
->getStorage('menu_link')->resetCache();
drupal_static_reset('_menu_build_tree');
drupal_static_reset('menu_tree');
drupal_static_reset('menu_tree_all_data');
......@@ -1028,9 +1028,9 @@ function menu_link_rebuild_defaults() {
// when possible.
return;
}
/** @var \Drupal\menu_link\MenuLinkStorageControllerInterface $menu_link_storage */
/** @var \Drupal\menu_link\MenuLinkStorageInterface $menu_link_storage */
$menu_link_storage = \Drupal::entityManager()
->getStorageController('menu_link');
->getStorage('menu_link');
$links = array();
$children = array();
$top_links = array();
......
......@@ -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
* configuration data.
......@@ -318,9 +318,9 @@ protected function importInvokeOwner($op, $name) {
}
$method = 'import' . ucfirst($op);
$entity_storage = $this->configManager->getEntityManager()->getStorageController($entity_type);
// Call to the configuration entity's storage controller to handle the
// configuration change.
$entity_storage = $this->configManager->getEntityManager()->getStorage($entity_type);
// Call to the configuration entity's storage to handle the configuration
// change.
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)));
}
......
......@@ -127,7 +127,7 @@ public function installDefaultConfig($type, $name) {
if ($entity_type = $this->configManager->getEntityTypeIdByName($name)) {
$entity_storage = $this->configManager
->getEntityManager()
->getStorageController($entity_type);
->getStorage($entity_type);
// It is possible that secondary writes can occur during configuration
// creation. Updates of such configuration are allowed.
if ($this->activeStorage->exists($name)) {
......
......@@ -188,7 +188,7 @@ public function findConfigEntityDependentsAsEntities($type, array $names) {
$definitions = $this->entityManager->getDefinitions();
foreach ($dependencies as $config_name => $dependency) {
// 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);
// 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
......@@ -201,10 +201,10 @@ public function findConfigEntityDependentsAsEntities($type, array $names) {
}
$entities_to_return = array();
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
// 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;
}
......
......@@ -11,7 +11,7 @@
use Drupal\Core\Database\Connection;
/**
* Defines the Database storage controller.
* Defines the Database storage.
*/
class DatabaseStorage implements StorageInterface {
......
......@@ -10,7 +10,7 @@
use Drupal\Component\Utility\String;
use Drupal\Core\Entity\Entity;
use Drupal\Core\Config\ConfigDuplicateUUIDException;
use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Language\Language;
/**
......@@ -256,8 +256,8 @@ public function toArray() {
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageControllerInterface $storage_controller) {
parent::preSave($storage_controller);
public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
// @todo When \Drupal\Core\Config\Entity\EntityWithPluginBagInterface moves
// to a trait, switch to class_uses() instead.
......@@ -270,7 +270,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
// Ensure this entity's UUID does not exist with a different ID, regardless
// of whether it's new or updated.
$matching_entities = $storage_controller->getQuery()
$matching_entities = $storage->getQuery()
->condition('uuid', $this->uuid())
->execute();
$matched_entity = reset($matching_entities);
......@@ -279,7 +279,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
}
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.
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())));
......
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\Core\Config\Entity\ConfigStorageController.
* Definition of Drupal\Core\Config\Entity\ConfigEntityStorage.
*/
namespace Drupal\Core\Config\Entity;
......@@ -11,7 +11,7 @@
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityMalformedException;
use Drupal\Core\Entity\EntityStorageControllerBase;
use Drupal\Core\Entity\EntityStorageBase;
use Drupal\Core\Config\Config;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
......@@ -21,7 +21,7 @@
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
* parts, separated by a dot:
......@@ -35,7 +35,7 @@
* after the config_prefix in a config name forms the entity ID. Additional or
* custom suffixes are not possible.
*/
class ConfigStorageController extends EntityStorageControllerBase implements ConfigStorageControllerInterface, ImportableEntityStorageInterface {
class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStorageInterface, ImportableEntityStorageInterface {
/**
* The UUID service.
......@@ -66,7 +66,7 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
protected $configStorage;
/**
* Constructs a ConfigStorageController object.
* Constructs a ConfigEntityStorage object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
......@@ -148,14 +148,14 @@ public function load($id) {
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::loadRevision().
* Implements Drupal\Core\Entity\EntityStorageInterface::loadRevision().
*/
public function loadRevision($revision_id) {
return FALSE;
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::deleteRevision().
* Implements Drupal\Core\Entity\EntityStorageInterface::deleteRevision().
*/
public function deleteRevision($revision_id) {
return NULL;
......@@ -184,8 +184,8 @@ public static function getIDFromConfigName($config_name, $config_prefix) {
* being loaded needs to be augmented with additional data from another
* table, such as loading node type into comments or vocabulary machine name
* into terms, however it can also support $conditions on different tables.
* See Drupal\comment\CommentStorageController::buildQuery() or
* Drupal\taxonomy\TermStorageController::buildQuery() for examples.
* See Drupal\comment\CommentStorage::buildQuery() or
* Drupal\taxonomy\TermStorage::buildQuery() for examples.
*
* @param $ids
* An array of entity IDs, or NULL to load all entities.
......@@ -221,7 +221,7 @@ protected function buildQuery($ids, $revision_id = FALSE) {
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::create().
* Implements Drupal\Core\Entity\EntityStorageInterface::create().
*/
public function create(array $values = array()) {
$class = $this->entityType->getClass();
......@@ -254,7 +254,7 @@ public function create(array $values = array()) {
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::delete().
* Implements Drupal\Core\Entity\EntityStorageInterface::delete().
*/
public function delete(array $entities) {
if (!$entities) {
......@@ -280,7 +280,7 @@ public function delete(array $entities) {
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::save().
* Implements Drupal\Core\Entity\EntityStorageInterface::save().
*
* @throws EntityMalformedException
* When attempting to save a configuration entity that has no ID.
......@@ -369,7 +369,7 @@ protected function invokeHook($hook, EntityInterface $entity) {
}
/**
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::getQueryServicename().
* Implements Drupal\Core\Entity\EntityStorageInterface::getQueryServicename().
*/
public function getQueryServicename() {
return 'entity.query.config';
......
......@@ -2,18 +2,18 @@
/**
* @file
* Contains \Drupal\Core\Config\Entity\ConfigStorageControllerInterface.
* Contains \Drupal\Core\Config\Entity\ConfigEntityStorageInterface.
*/
namespace Drupal\Core\Config\Entity;
use Drupal\Core\Config\Config;
use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
/**
* Provides an interface for configuration entity storage.
*/
interface ConfigStorageControllerInterface extends EntityStorageControllerInterface {
interface ConfigEntityStorageInterface extends EntityStorageInterface {
/**
* Returns the config prefix used by the configuration entity type.
......
......@@ -26,7 +26,7 @@ class ConfigEntityType extends EntityType {
*/
public function getControllerClasses() {
return parent::getControllerClasses() + array(
'storage' => 'Drupal\Core\Config\Entity\ConfigStorageController',
'storage' => 'Drupal\Core\Config\Entity\ConfigEntityStorage',
);
}
......
......@@ -8,7 +8,7 @@
namespace Drupal\Core\Config\Entity;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormInterface;
......@@ -48,7 +48,7 @@ abstract class DraggableListBuilder extends ConfigEntityListBuilder implements F
/**
* {@inheritdoc}
*/
public function __construct(EntityTypeInterface $entity_type, EntityStorageControllerInterface $storage) {
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage) {
parent::__construct($entity_type, $storage);
// Check if the entity type supports weighting.
......
......@@ -30,7 +30,7 @@ class Date {
/**
* The date format storage.
*
* @var \Drupal\Core\Entity\EntityStorageControllerInterface
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $dateFormatStorage;
......@@ -83,7 +83,7 @@ class Date {
* The configuration factory.
*/
public function __construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, TranslationInterface $translation, ConfigFactoryInterface $config_factory) {
$this->dateFormatStorage = $entity_manager->getStorageController('date_format');
$this->dateFormatStorage = $entity_manager->getStorage('date_format');
$this->languageManager = $language_manager;
$this->stringTranslation = $translation;
$this->configFactory = $config_factory;
......
......@@ -211,7 +211,7 @@ public function isTranslatable() {
/**
* {@inheritdoc}
*/
public function preSaveRevision(EntityStorageControllerInterface $storage_controller, \stdClass $record) {
public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
}
/**
......@@ -695,7 +695,7 @@ public function addTranslation($langcode, array $values = array()) {
$entity_type = $this->getEntityType();
$default_values = array($entity_type->getKey('bundle') => $this->bundle, 'langcode' => $langcode);
$entity = $this->entityManager()
->getStorageController($this->getEntityTypeId())
->getStorage($this->getEntityTypeId())
->create($default_values);
foreach ($entity as $name => $field) {
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\Core\Entity\DatabaseStorageController.
* Contains \Drupal\Core\Entity\ContentEntityDatabaseStorage.
*/
namespace Drupal\Core\Entity;
......@@ -20,12 +20,12 @@
/**
* Defines a base entity controller class.
*
* Default implementation of Drupal\Core\Entity\EntityStorageControllerInterface.
* Default implementation of Drupal\Core\Entity\EntityStorageInterface.
*
* This class can be used as-is by most simple entity types. Entity types
* requiring special handling can extend the class.
*/
class FieldableDatabaseStorageController extends FieldableEntityStorageControllerBase {
class ContentEntityDatabaseStorage extends ContentEntityStorageBase {
/**
* Name of entity's revision database table field, if it supports revisions.
......@@ -90,7 +90,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
}
/**
* Constructs a DatabaseStorageController object.
* Constructs a ContentEntityDatabaseStorage object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
......@@ -313,7 +313,7 @@ protected function attachPropertyData(array &$entities) {
}
/**
* Implements \Drupal\Core\Entity\EntityStorageControllerInterface::loadRevision().
* Implements \Drupal\Core\Entity\EntityStorageInterface::loadRevision().
*/
public function loadRevision($revision_id) {
// Build and execute the query.
......@@ -330,7 +330,7 @@ public function loadRevision($revision_id) {
}
/**
* Implements \Drupal\Core\Entity\EntityStorageControllerInterface::deleteRevision().
* Implements \Drupal\Core\Entity\EntityStorageInterface::deleteRevision().
*/
public function deleteRevision($revision_id) {
if ($revision = $this->loadRevision($revision_id)) {
......@@ -379,7 +379,7 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value
* being loaded needs to be augmented with additional data from another
* table, such as loading node type into comments or vocabulary machine name
* into terms, however it can also support $conditions on different tables.
* See Drupal\comment\CommentStorageController::buildQuery() for an example.
* See Drupal\comment\CommentStorage::buildQuery() for an example.
*
* @param array|null $ids
* An array of entity IDs, or NULL to load all entities.
......@@ -445,7 +445,7 @@ protected function buildQuery($ids, $revision_id = FALSE) {
* hook_node_load() or hook_user_load(). If your hook_TYPE_load()
* expects special parameters apart from the queried entities, you can set
* $this->hookLoadArguments prior to calling the method.
* See Drupal\node\NodeStorageController::attachLoad() for an example.
* See Drupal\node\NodeStorage::attachLoad() for an example.