Commit 3da9d8b2 authored by Dries's avatar Dries

Issue #1772102 by fago: Remove StorageControllerInterface in favour of...

Issue #1772102 by fago: Remove StorageControllerInterface in favour of EntityStorageControllerInterface.
parent a59d92e0
......@@ -9,12 +9,12 @@
use Drupal\Component\Uuid\Uuid;
use Drupal\entity\EntityInterface;
use Drupal\entity\StorageControllerInterface;
use Drupal\entity\EntityStorageControllerInterface;
/**
* Defines the storage controller class for configuration entities.
*/
class ConfigStorageController implements StorageControllerInterface {
class ConfigStorageController implements EntityStorageControllerInterface {
/**
* Entity type for this controller instance.
......@@ -56,7 +56,7 @@ class ConfigStorageController implements StorageControllerInterface {
protected $uuidKey = 'uuid';
/**
* Implements Drupal\entity\StorageControllerInterface::__construct().
* Implements Drupal\entity\EntityStorageControllerInterface::__construct().
*
* Sets basic variables.
*/
......@@ -68,7 +68,7 @@ public function __construct($entityType) {
}
/**
* Implements Drupal\entity\StorageControllerInterface::resetCache().
* Implements Drupal\entity\EntityStorageControllerInterface::resetCache().
*/
public function resetCache(array $ids = NULL) {
// The configuration system is fast enough and/or implements its own
......@@ -76,7 +76,7 @@ public function resetCache(array $ids = NULL) {
}
/**
* Implements Drupal\entity\StorageControllerInterface::load().
* Implements Drupal\entity\EntityStorageControllerInterface::load().
*/
public function load(array $ids = NULL) {
$entities = array();
......@@ -115,14 +115,14 @@ public function load(array $ids = NULL) {
}
/**
* Implements Drupal\entity\StorageControllerInterface::loadRevision().
* Implements Drupal\entity\EntityStorageControllerInterface::loadRevision().
*/
public function loadRevision($revision_id) {
return FALSE;
}
/**
* Implements Drupal\entity\StorageControllerInterface::loadByProperties().
* Implements Drupal\entity\EntityStorageControllerInterface::loadByProperties().
*/
public function loadByProperties(array $values = array()) {
return array();
......@@ -209,7 +209,7 @@ protected function attachLoad(&$queried_entities, $revision_id = FALSE) {
}
/**
* Implements Drupal\entity\StorageControllerInterface::create().
* Implements Drupal\entity\EntityStorageControllerInterface::create().
*/
public function create(array $values) {
$class = isset($this->entityInfo['entity class']) ? $this->entityInfo['entity class'] : 'Drupal\entity\Entity';
......@@ -226,7 +226,7 @@ public function create(array $values) {
}
/**
* Implements Drupal\entity\StorageControllerInterface::delete().
* Implements Drupal\entity\EntityStorageControllerInterface::delete().
*/
public function delete($ids) {
$entities = $ids ? $this->load($ids) : FALSE;
......@@ -252,7 +252,7 @@ public function delete($ids) {
}
/**
* Implements Drupal\entity\StorageControllerInterface::save().
* Implements Drupal\entity\EntityStorageControllerInterface::save().
*/
public function save(EntityInterface $entity) {
$prefix = $this->entityInfo['config prefix'] . '.';
......
......@@ -25,7 +25,7 @@
* Drupal\entity\Entity. The entity class must implement EntityInterface.
* - controller class: The name of the class that is used to load the objects.
* The class has to implement the
* Drupal\entity\StorageControllerInterface interface. Leave blank
* Drupal\entity\EntityStorageControllerInterface interface. Leave blank
* to use the Drupal\entity\DatabaseStorageController implementation.
* - form controller class: An associative array where the keys are the names
* of the different form operations (such as creation, editing or deletion)
......@@ -229,7 +229,7 @@ function hook_entity_info() {
*/
function hook_entity_info_alter(&$entity_info) {
// Set the controller class for nodes to an alternate implementation of the
// Drupal\entity\StorageControllerInterface interface.
// Drupal\entity\EntityStorageControllerInterface interface.
$entity_info['node']['controller class'] = 'Drupal\mymodule\MyCustomNodeStorageController';
}
......
......@@ -145,7 +145,7 @@ function entity_info_cache_clear() {
*
* @see hook_entity_info()
* @see entity_load_multiple()
* @see Drupal\entity\StorageControllerInterface
* @see Drupal\entity\EntityStorageControllerInterface
* @see Drupal\entity\DatabaseStorageController
* @see Drupal\entity\EntityFieldQuery
*/
......@@ -217,11 +217,11 @@ function entity_load_by_uuid($entity_type, $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\entity\StorageControllerInterface interface. By default,
* Drupal\entity\EntityStorageControllerInterface interface. By default,
* Drupal\entity\DatabaseStorageController is used. Entity types can
* specify that a different class should be used by setting the
* 'controller class' key in hook_entity_info(). These classes can either
* implement the Drupal\entity\StorageControllerInterface interface, or,
* implement the Drupal\entity\EntityStorageControllerInterface interface, or,
* most commonly, extend the Drupal\entity\DatabaseStorageController
* class. See node_entity_info() and the NodeStorageController in node.module as
* an example.
......@@ -237,7 +237,7 @@ function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) {
* An array of entity objects indexed by their ids.
*
* @see hook_entity_info()
* @see Drupal\entity\StorageControllerInterface
* @see Drupal\entity\EntityStorageControllerInterface
* @see Drupal\entity\DatabaseStorageController
* @see Drupal\entity\EntityFieldQuery
*/
......@@ -317,7 +317,7 @@ function entity_create($entity_type, array $values) {
/**
* Gets the entity controller class for an entity type.
*
* @return Drupal\entity\StorageControllerInterface
* @return Drupal\entity\EntityStorageControllerInterface
*/
function entity_get_controller($entity_type) {
$controllers = &drupal_static(__FUNCTION__, array());
......
......@@ -15,7 +15,7 @@
/**
* Defines a base entity controller class.
*
* Default implementation of Drupal\entity\DatabaseStorageControllerInterface.
* Default implementation of Drupal\entity\EntityStorageControllerInterface.
*
* This class can be used as-is by most simple entity types. Entity types
* requiring special handling can extend the class.
......
......@@ -18,6 +18,95 @@
* Drupal\entity\DatabaseStorageController instead of implementing this
* interface directly.
*/
interface EntityStorageControllerInterface extends StorageControllerInterface {
interface EntityStorageControllerInterface {
/**
* Constructs a new Drupal\entity\EntityStorageControllerInterface object.
*
* @param $entityType
* The entity type for which the instance is created.
*/
public function __construct($entityType);
/**
* Resets the internal, static entity cache.
*
* @param $ids
* (optional) If specified, the cache is reset for the entities with the
* given ids only.
*/
public function resetCache(array $ids = NULL);
/**
* Loads one or more entities.
*
* @param $ids
* An array of entity IDs, or FALSE to load all entities.
*
* @return
* An array of entity objects indexed by their ids.
*/
public function load(array $ids = NULL);
/**
* Load a specific entity revision.
*
* @param int $revision_id
* The revision id.
*
* @return Drupal\entity\EntityInterface|false
* The specified entity revision or FALSE if not found.
*/
public function loadRevision($revision_id);
/**
* Load entities by their property values.
*
* @param array $values
* An associative array where the keys are the property names and the
* values are the values those properties must have.
*
* @return array
* An array of entity objects indexed by their ids.
*/
public function loadByProperties(array $values);
/**
* Constructs a new entity object, without permanently saving it.
*
* @param $values
* An array of values to set, keyed by property name. If the entity type has
* bundles the bundle key has to be specified.
*
* @return Drupal\entity\EntityInterface
* A new entity object.
*/
public function create(array $values);
/**
* Deletes permanently saved entities.
*
* @param $ids
* An array of entity IDs.
*
* @throws Drupal\entity\EntityStorageException
* In case of failures, an exception is thrown.
*/
public function delete($ids);
/**
* Saves the entity permanently.
*
* @param Drupal\entity\EntityInterface $entity
* The entity to save.
*
* @return
* SAVED_NEW or SAVED_UPDATED is returned depending on the operation
* performed.
*
* @throws Drupal\entity\EntityStorageException
* In case of failures, an exception is thrown.
*/
public function save(EntityInterface $entity);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment