Drupal 8  8.0.2
ContentEntityStorageBase Class Reference
Inheritance diagram for ContentEntityStorageBase:

Public Member Functions

 __construct (EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, CacheBackendInterface $cache)
 
 hasData ()
 
 createTranslation (ContentEntityInterface $entity, $langcode, array $values=[])
 
 onFieldStorageDefinitionCreate (FieldStorageDefinitionInterface $storage_definition)
 
 onFieldStorageDefinitionUpdate (FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original)
 
 onFieldStorageDefinitionDelete (FieldStorageDefinitionInterface $storage_definition)
 
 onFieldDefinitionCreate (FieldDefinitionInterface $field_definition)
 
 onFieldDefinitionUpdate (FieldDefinitionInterface $field_definition, FieldDefinitionInterface $original)
 
 onFieldDefinitionDelete (FieldDefinitionInterface $field_definition)
 
 purgeFieldData (FieldDefinitionInterface $field_definition, $batch_size)
 
 finalizePurge (FieldStorageDefinitionInterface $storage_definition)
 
 loadRevision ($revision_id)
 
 resetCache (array $ids=NULL)
 
- Public Member Functions inherited from EntityStorageBase
 __construct (EntityTypeInterface $entity_type)
 
 getEntityTypeId ()
 
 getEntityType ()
 
 loadUnchanged ($id)
 
 resetCache (array $ids=NULL)
 
 create (array $values=array())
 
 load ($id)
 
 loadMultiple (array $ids=NULL)
 
 delete (array $entities)
 
 save (EntityInterface $entity)
 
 loadByProperties (array $values=array())
 
 getQuery ($conjunction= 'AND')
 
 getAggregateQuery ($conjunction= 'AND')
 
- Public Member Functions inherited from EntityHandlerBase
 setModuleHandler (ModuleHandlerInterface $module_handler)
 
- Public Member Functions inherited from EntityStorageInterface
 deleteRevision ($revision_id)
 
- Public Member Functions inherited from FieldableEntityStorageInterface
 countFieldData ($storage_definition, $as_bool=FALSE)
 

Static Public Member Functions

static createInstance (ContainerInterface $container, EntityTypeInterface $entity_type)
 

Protected Member Functions

 doCreate (array $values)
 
 initFieldValues (ContentEntityInterface $entity, array $values=[], array $field_names=[])
 
 readFieldItemsToPurge (FieldDefinitionInterface $field_definition, $batch_size)
 
 purgeFieldItems (ContentEntityInterface $entity, FieldDefinitionInterface $field_definition)
 
 doLoadRevisionFieldItems ($revision_id)
 
 doSaveFieldItems (ContentEntityInterface $entity, array $names=[])
 
 doDeleteFieldItems ($entities)
 
 doDeleteRevisionFieldItems (ContentEntityInterface $revision)
 
 invokeTranslationHooks (ContentEntityInterface $entity)
 
 invokeStorageLoadHook (array &$entities)
 
 invokeFieldMethod ($method, ContentEntityInterface $entity)
 
 invokeFieldPostSave (ContentEntityInterface $entity, $update)
 
 hasFieldValueChanged (FieldDefinitionInterface $field_definition, ContentEntityInterface $entity, ContentEntityInterface $original)
 
 populateAffectedRevisionTranslations (ContentEntityInterface $entity)
 
 cleanIds (array $ids)
 
 getFromPersistentCache (array &$ids=NULL)
 
 setPersistentCache ($entities)
 
 buildCacheId ($id)
 
- Protected Member Functions inherited from EntityStorageBase
 getFromStaticCache (array $ids)
 
 setStaticCache (array $entities)
 
 invokeHook ($hook, EntityInterface $entity)
 
 doCreate (array $values)
 
 doLoadMultiple (array $ids=NULL)
 
 postLoad (array &$entities)
 
 mapFromStorageRecords (array $records)
 
 has ($id, EntityInterface $entity)
 
 doDelete ($entities)
 
 doPreSave (EntityInterface $entity)
 
 doSave ($id, EntityInterface $entity)
 
 doPostSave (EntityInterface $entity, $update)
 
 buildPropertyQuery (QueryInterface $entity_query, array $values)
 
 getQueryServiceName ()
 
- Protected Member Functions inherited from EntityHandlerBase
 moduleHandler ()
 

Protected Attributes

 $bundleKey = FALSE
 
 $entityManager
 
 $cacheBackend
 
- Protected Attributes inherited from EntityStorageBase
 $entities = array()
 
 $entityTypeId
 
 $entityType
 
 $idKey
 
 $uuidKey
 
 $langcodeKey
 
 $uuidService
 
 $entityClass
 
- Protected Attributes inherited from EntityHandlerBase
 $moduleHandler
 

Additional Inherited Members

- Data Fields inherited from EntityStorageInterface
const FIELD_LOAD_CURRENT = 'FIELD_LOAD_CURRENT'
 
const FIELD_LOAD_REVISION = 'FIELD_LOAD_REVISION'
 

Detailed Description

Base class for content entity storage handlers.

Constructor & Destructor Documentation

__construct ( EntityTypeInterface  $entity_type,
EntityManagerInterface  $entity_manager,
CacheBackendInterface  $cache 
)

Constructs a ContentEntityStorageBase object.

Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe entity type definition.
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager.
\Drupal\Core\Cache\CacheBackendInterface$cacheThe cache backend to be used.

References Drupal\entityManager().

Here is the call graph for this function:

Member Function Documentation

buildCacheId (   $id)
protected

Builds the cache ID for the passed in entity ID.

Parameters
int$idEntity ID for which the cache ID should be built.
Returns
string Cache ID that can be passed to the cache backend.
cleanIds ( array  $ids)
protected

Ensures integer entity IDs are valid.

The identifier sanitization provided by this method has been introduced as Drupal used to rely on the database to facilitate this, which worked correctly with MySQL but led to errors with other DBMS such as PostgreSQL.

Parameters
array$idsThe entity IDs to verify.
Returns
array The sanitized list of entity IDs.

References Drupal\entityManager().

Referenced by SqlContentEntityStorage\getFromStorage().

Here is the call graph for this function:

Here is the caller graph for this function:

static createInstance ( ContainerInterface  $container,
EntityTypeInterface  $entity_type 
)
static

{Instantiates a new instance of this entity handler.This is a factory method that returns a new instance of this object. The factory should pass any needed dependencies into the constructor of this object, but not the container itself. Every call to this method must return a new instance of this object; that is, it may not implement a singleton.

Parameters
\Symfony\Component\DependencyInjection\ContainerInterface$containerThe service container this object should use.
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe entity type definition.
Returns
static A new instance of the entity handler.
}

Implements EntityHandlerInterface.

References EntityTypeInterface\get().

Here is the call graph for this function:

createTranslation ( ContentEntityInterface  $entity,
  $langcode,
array  $values = [] 
)

{Constructs a new entity translation object, without permanently saving it.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity object being translated.
string$langcodeThe translation language code.
array$values(optional) An associative array of initial field values keyed by field name. If none is provided default values will be applied.
Returns
A new entity translation object.
}

Implements ContentEntityStorageInterface.

References EntityStorageBase\getEntityType(), FieldDefinitionInterface\getName(), TranslatableInterface\getTranslation(), ContentEntityStorageBase\initFieldValues(), and EntityStorageBase\invokeHook().

Here is the call graph for this function:

doCreate ( array  $values)
protected

{}

References ContentEntityStorageBase\initFieldValues().

Here is the call graph for this function:

doDeleteFieldItems (   $entities)
abstractprotected

Deletes entity field values from the storage.

Parameters
\Drupal\Core\Entity\ContentEntityInterface[]$entities An array of entity objects to be deleted.
doDeleteRevisionFieldItems ( ContentEntityInterface  $revision)
abstractprotected

Deletes field values of an entity revision from the storage.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$revisionAn entity revision object to be deleted.
doLoadRevisionFieldItems (   $revision_id)
abstractprotected

Actually loads revision field item values from the storage.

Parameters
int | string$revision_idThe revision identifier.
Returns
|null The specified entity revision or NULL if not found.

Referenced by ContentEntityStorageBase\loadRevision().

Here is the caller graph for this function:

doSaveFieldItems ( ContentEntityInterface  $entity,
array  $names = [] 
)
abstractprotected

Writes entity field values to the storage.

This method is responsible for allocating entity and revision identifiers and updating the entity object with their values.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity object.
string[]$names (optional) The name of the fields to be written to the storage. If an empty value is passed all field values are saved.
finalizePurge ( FieldStorageDefinitionInterface  $storage_definition)

{Performs final cleanup after all data of a field has been purged.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe field being purged.
}

Implements DynamicallyFieldableEntityStorageInterface.

getFromPersistentCache ( array &  $ids = NULL)
protected

Gets entities from the persistent cache backend.

Parameters
array | null&$idsIf not empty, return entities that match these IDs. IDs that were found will be removed from the list.
Returns
[] Array of entities from the persistent cache.

Referenced by SqlContentEntityStorage\doLoadMultiple().

Here is the caller graph for this function:

hasData ( )

{Determines if the storage contains any data.

Returns
bool TRUE if the storage contains data, FALSE if not.
}

Implements DynamicallyFieldableEntityStorageInterface.

References EntityStorageBase\getQuery().

Here is the call graph for this function:

hasFieldValueChanged ( FieldDefinitionInterface  $field_definition,
ContentEntityInterface  $entity,
ContentEntityInterface  $original 
)
protected

Checks whether the field values changed compared to the original entity.

Parameters
\Drupal\Core\Field\FieldDefinitionInterface$field_definitionField definition of field to compare for changes.
\Drupal\Core\Entity\ContentEntityInterface$entityEntity to check for field changes.
\Drupal\Core\Entity\ContentEntityInterface$originalOriginal entity to compare against.
Returns
bool True if the field value changed from the original entity.

References FieldDefinitionInterface\getName(), TranslatableInterface\getTranslation(), and TranslatableInterface\getTranslationLanguages().

Here is the call graph for this function:

initFieldValues ( ContentEntityInterface  $entity,
array  $values = [],
array  $field_names = [] 
)
protected

Initializes field values.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityAn entity object.
array$values(optional) An associative array of initial field values keyed by field name. If none is provided default values will be applied.
array$field_names(optional) An associative array of field names to be initialized. If none is provided all fields will be initialized.

References FieldableEntityInterface\get(), and EntityStorageBase\invokeHook().

Referenced by ContentEntityStorageBase\createTranslation(), and ContentEntityStorageBase\doCreate().

Here is the call graph for this function:

Here is the caller graph for this function:

invokeFieldMethod (   $method,
ContentEntityInterface  $entity 
)
protected

Invokes a method on the Field objects within an entity.

Any argument passed will be forwarded to the invoked method.

Parameters
string$methodThe name of the method to be invoked.
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity object.
Returns
array A multidimensional associative array of results, keyed by entity translation language code and field name.

References TranslatableInterface\getTranslation(), and TranslatableInterface\getTranslationLanguages().

Here is the call graph for this function:

invokeFieldPostSave ( ContentEntityInterface  $entity,
  $update 
)
protected

Invokes the post save method on the Field objects within an entity.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity object.
bool$updateSpecifies whether the entity is being updated or created.
invokeStorageLoadHook ( array &  $entities)
protected

Invokes hook_entity_storage_load().

Parameters
\Drupal\Core\Entity\ContentEntityInterface[]$entities List of entities, keyed on the entity ID.

References EntityHandlerBase\moduleHandler().

Referenced by SqlContentEntityStorage\doLoadMultiple(), and ContentEntityStorageBase\loadRevision().

Here is the call graph for this function:

Here is the caller graph for this function:

invokeTranslationHooks ( ContentEntityInterface  $entity)
protected

Checks translation statuses and invoke the related hooks if needed.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity being saved.

References TranslatableInterface\getTranslation(), TranslatableInterface\getTranslationLanguages(), and EntityStorageBase\invokeHook().

Here is the call graph for this function:

loadRevision (   $revision_id)

{Load a specific entity revision.

Parameters
int | string$revision_idThe revision id.
Returns
|null The specified entity revision or NULL if not found.
}

Implements EntityStorageInterface.

References ContentEntityStorageBase\doLoadRevisionFieldItems(), ContentEntityStorageBase\invokeStorageLoadHook(), and EntityStorageBase\postLoad().

Here is the call graph for this function:

onFieldDefinitionCreate ( FieldDefinitionInterface  $field_definition)

{Reacts to the creation of a field.

Parameters
\Drupal\Core\Field\FieldDefinitionInterface$field_definitionThe field definition created.
}

Implements FieldDefinitionListenerInterface.

onFieldDefinitionDelete ( FieldDefinitionInterface  $field_definition)

{Reacts to the deletion of a field.Stored values should not be wiped at once, but marked as 'deleted' so that they can go through a proper purge process later on.

Parameters
\Drupal\Core\Field\FieldDefinitionInterface$field_definitionThe field definition being deleted.
}

Implements FieldDefinitionListenerInterface.

onFieldDefinitionUpdate ( FieldDefinitionInterface  $field_definition,
FieldDefinitionInterface  $original 
)

{Reacts to the update of a field.

Parameters
\Drupal\Core\Field\FieldDefinitionInterface$field_definitionThe field definition being updated.
\Drupal\Core\Field\FieldDefinitionInterface$originalThe original field definition; i.e., the definition before the update.
}

Implements FieldDefinitionListenerInterface.

onFieldStorageDefinitionCreate ( FieldStorageDefinitionInterface  $storage_definition)

{Reacts to the creation of a field storage definition.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe definition being created.
}

Implements FieldStorageDefinitionListenerInterface.

onFieldStorageDefinitionDelete ( FieldStorageDefinitionInterface  $storage_definition)

{Reacts to the deletion of a field storage definition.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe field being deleted.
}

Implements FieldStorageDefinitionListenerInterface.

onFieldStorageDefinitionUpdate ( FieldStorageDefinitionInterface  $storage_definition,
FieldStorageDefinitionInterface  $original 
)

{Reacts to the update of a field storage definition.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe field being updated.
\Drupal\Core\Field\FieldStorageDefinitionInterface$originalThe original storage definition; i.e., the definition before the update.
Exceptions
\Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenExceptionThrown when the update to the field is forbidden.
}

Implements FieldStorageDefinitionListenerInterface.

populateAffectedRevisionTranslations ( ContentEntityInterface  $entity)
protected

Populates the affected flag for all the revision translations.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityAn entity object being saved.

References TranslatableInterface\getTranslation(), and TranslatableInterface\getTranslationLanguages().

Here is the call graph for this function:

purgeFieldData ( FieldDefinitionInterface  $field_definition,
  $batch_size 
)

{Purges a batch of field data.

Parameters
\Drupal\Core\Field\FieldDefinitionInterface$field_definitionThe deleted field whose data is being purged.
$batch_sizeThe maximum number of field data records to purge before returning, relating to the count of field data records returned by ::countFieldData().
Returns
int The number of field data records that have been purged.
}

Implements DynamicallyFieldableEntityStorageInterface.

References ContentEntityStorageBase\purgeFieldItems(), and ContentEntityStorageBase\readFieldItemsToPurge().

Here is the call graph for this function:

purgeFieldItems ( ContentEntityInterface  $entity,
FieldDefinitionInterface  $field_definition 
)
abstractprotected

Removes field items from storage per entity during purge.

Parameters
ContentEntityInterface$entityThe entity revision, whose values are being purged.
\Drupal\Core\Field\FieldDefinitionInterface$field_definitionThe field whose values are bing purged.

Referenced by ContentEntityStorageBase\purgeFieldData().

Here is the caller graph for this function:

readFieldItemsToPurge ( FieldDefinitionInterface  $field_definition,
  $batch_size 
)
abstractprotected

Reads values to be purged for a single field.

This method is called during field data purge, on fields for which onFieldDefinitionDelete() has previously run.

Parameters
\Drupal\Core\Field\FieldDefinitionInterface$field_definitionThe field definition.
$batch_sizeThe maximum number of field data records to purge before returning.
Returns
[] An array of field item lists, keyed by entity revision id.

Referenced by ContentEntityStorageBase\purgeFieldData().

Here is the caller graph for this function:

resetCache ( array  $ids = NULL)

{Resets the internal, static entity cache.

Parameters
$ids(optional) If specified, the cache is reset for the entities with the given ids only.
}

Implements EntityStorageInterface.

References Cache\invalidateTags().

Referenced by UserStorage\deleteRoleReferences(), UserStorage\updateLastAccessTimestamp(), and UserStorage\updateLastLoginTimestamp().

Here is the call graph for this function:

Here is the caller graph for this function:

setPersistentCache (   $entities)
protected

Stores entities in the persistent cache backend.

Parameters
\Drupal\Core\Entity\ContentEntityInterface[]$entities Entities to store in the cache.

References CacheBackendInterface\CACHE_PERMANENT.

Referenced by SqlContentEntityStorage\doLoadMultiple().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: