Drupal 8  8.0.2
SqlContentEntityStorage Class Reference
Inheritance diagram for SqlContentEntityStorage:

Public Member Functions

 getFieldStorageDefinitions ()
 
 __construct (EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager, CacheBackendInterface $cache, LanguageManagerInterface $language_manager)
 
 getBaseTable ()
 
 getRevisionTable ()
 
 getDataTable ()
 
 getRevisionDataTable ()
 
 setEntityType (EntityTypeInterface $entity_type)
 
 getTableMapping (array $storage_definitions=NULL)
 
 delete (array $entities)
 
 save (EntityInterface $entity)
 
 requiresEntityStorageSchemaChanges (EntityTypeInterface $entity_type, EntityTypeInterface $original)
 
 requiresFieldStorageSchemaChanges (FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original)
 
 requiresEntityDataMigration (EntityTypeInterface $entity_type, EntityTypeInterface $original)
 
 requiresFieldDataMigration (FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original)
 
 onEntityTypeCreate (EntityTypeInterface $entity_type)
 
 onEntityTypeUpdate (EntityTypeInterface $entity_type, EntityTypeInterface $original)
 
 onEntityTypeDelete (EntityTypeInterface $entity_type)
 
 onFieldStorageDefinitionCreate (FieldStorageDefinitionInterface $storage_definition)
 
 onFieldStorageDefinitionUpdate (FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original)
 
 onFieldStorageDefinitionDelete (FieldStorageDefinitionInterface $storage_definition)
 
 onFieldDefinitionDelete (FieldDefinitionInterface $field_definition)
 
 onBundleCreate ($bundle, $entity_type_id)
 
 onBundleDelete ($bundle, $entity_type_id)
 
 finalizePurge (FieldStorageDefinitionInterface $storage_definition)
 
 countFieldData ($storage_definition, $as_bool=FALSE)
 
- Public Member Functions inherited from ContentEntityStorageBase
 __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)
 

Static Public Member Functions

static createInstance (ContainerInterface $container, EntityTypeInterface $entity_type)
 
- Static Public Member Functions inherited from ContentEntityStorageBase
static createInstance (ContainerInterface $container, EntityTypeInterface $entity_type)
 

Protected Member Functions

 initTableLayout ()
 
 getStorageSchema ()
 
 doLoadMultiple (array $ids=NULL)
 
 getFromStorage (array $ids=NULL)
 
 mapFromStorageRecords (array $records, $load_from_revision=FALSE)
 
 loadFromSharedTables (array &$values, array &$translations)
 
 doLoadRevisionFieldItems ($revision_id)
 
 doDeleteRevisionFieldItems (ContentEntityInterface $revision)
 
 buildPropertyQuery (QueryInterface $entity_query, array $values)
 
 buildQuery ($ids, $revision_id=FALSE)
 
 doDeleteFieldItems ($entities)
 
 doSaveFieldItems (ContentEntityInterface $entity, array $names=[])
 
 has ($id, EntityInterface $entity)
 
 saveToSharedTables (ContentEntityInterface $entity, $table_name=NULL, $new_revision=NULL)
 
 mapToStorageRecord (ContentEntityInterface $entity, $table_name=NULL)
 
 isColumnSerial ($table_name, $schema_name)
 
 mapToDataStorageRecord (EntityInterface $entity, $table_name=NULL)
 
 saveRevision (ContentEntityInterface $entity)
 
 getQueryServiceName ()
 
 loadFromDedicatedTables (array &$values, $load_from_revision)
 
 saveToDedicatedTables (ContentEntityInterface $entity, $update=TRUE, $names=array())
 
 deleteFromDedicatedTables (ContentEntityInterface $entity)
 
 deleteRevisionFromDedicatedTables (ContentEntityInterface $entity)
 
 wrapSchemaException (callable $callback)
 
 readFieldItemsToPurge (FieldDefinitionInterface $field_definition, $batch_size)
 
 purgeFieldItems (ContentEntityInterface $entity, FieldDefinitionInterface $field_definition)
 
 storageDefinitionIsDeleted (FieldStorageDefinitionInterface $storage_definition)
 
- Protected Member Functions inherited from ContentEntityStorageBase
 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

 $tableMapping
 
 $revisionKey = FALSE
 
 $langcodeKey = FALSE
 
 $defaultLangcodeKey = FALSE
 
 $baseTable
 
 $revisionTable
 
 $dataTable
 
 $revisionDataTable
 
 $database
 
 $storageSchema
 
 $languageManager
 
- Protected Attributes inherited from ContentEntityStorageBase
 $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

A content entity database storage implementation.

This class can be used as-is by most content entity types. Entity types requiring special handling can extend the class.

The class uses internally in order to automatically generate the database schema based on the defined base fields. Entity types can override the schema handler to customize the generated schema; e.g., to add additional indexes.

Constructor & Destructor Documentation

__construct ( EntityTypeInterface  $entity_type,
Connection  $database,
EntityManagerInterface  $entity_manager,
CacheBackendInterface  $cache,
LanguageManagerInterface  $language_manager 
)

Constructs a SqlContentEntityStorage object.

Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe entity type definition.
\Drupal\Core\Database\Connection$databaseThe database connection to be used.
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager.
\Drupal\Core\Cache\CacheBackendInterface$cache_backendThe cache backend to be used.
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.

References Drupal\database(), SqlContentEntityStorage\initTableLayout(), and Drupal\languageManager().

Here is the call graph for this function:

Member Function Documentation

buildPropertyQuery ( QueryInterface  $entity_query,
array  $values 
)
protected

{}

buildQuery (   $ids,
  $revision_id = FALSE 
)
protected

Builds the query to load the entity.

This has full revision support. For entities requiring special queries, the class can be extended, and the default query can be constructed by calling parent::buildQuery(). This is usually necessary when the object 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::buildQuery() for an example.

Parameters
array | null$idsAn array of entity IDs, or NULL to load all entities.
$revision_idThe ID of the revision to load, or FALSE if this query is asking for the most current revision(s).
Returns
A SelectQuery object for loading the entity.

References Drupal\database(), and SqlContentEntityStorage\getTableMapping().

Referenced by SqlContentEntityStorage\doLoadRevisionFieldItems(), and SqlContentEntityStorage\getFromStorage().

Here is the call graph for this function:

Here is the caller graph for this function:

countFieldData (   $storage_definition,
  $as_bool = FALSE 
)

{Determines the number of entities with values for a given field.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe field for which to count data records.
bool$as_bool(Optional) Optimises the query for checking whether there are any records or not. Defaults to FALSE.
Returns
bool|int The number of entities. If $as_bool parameter is TRUE then the value will either be TRUE or FALSE.
See Also
::purgeFieldData()
}

Implements FieldableEntityStorageInterface.

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:

delete ( array  $entities)

{Deletes permanently saved entities.

Parameters
array$entitiesAn array of entity objects to delete.
Exceptions
\Drupal\Core\Entity\EntityStorageExceptionIn case of failures, an exception is thrown.
}

Implements EntityStorageInterface.

References Drupal\database().

Here is the call graph for this function:

deleteFromDedicatedTables ( ContentEntityInterface  $entity)
protected

Deletes values of fields in dedicated tables for all revisions.

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

References EntityInterface\bundle(), EntityInterface\getEntityTypeId(), and EntityInterface\id().

Referenced by SqlContentEntityStorage\doDeleteFieldItems().

Here is the call graph for this function:

Here is the caller graph for this function:

deleteRevisionFromDedicatedTables ( ContentEntityInterface  $entity)
protected

Deletes values of fields in dedicated tables for all revisions.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity. It must have a revision ID.

References EntityInterface\bundle(), EntityInterface\getEntityTypeId(), RevisionableInterface\getRevisionId(), and EntityInterface\id().

Referenced by SqlContentEntityStorage\doDeleteRevisionFieldItems().

Here is the call graph for this function:

Here is the caller graph for this function:

doDeleteFieldItems (   $entities)
protected

{}

References Drupal\database(), and SqlContentEntityStorage\deleteFromDedicatedTables().

Here is the call graph for this function:

doDeleteRevisionFieldItems ( ContentEntityInterface  $revision)
protected

{}

References Drupal\database(), SqlContentEntityStorage\deleteRevisionFromDedicatedTables(), and RevisionableInterface\getRevisionId().

Here is the call graph for this function:

doLoadMultiple ( array  $ids = NULL)
protected

{}

References ContentEntityStorageBase\getFromPersistentCache(), SqlContentEntityStorage\getFromStorage(), ContentEntityStorageBase\invokeStorageLoadHook(), and ContentEntityStorageBase\setPersistentCache().

Here is the call graph for this function:

doLoadRevisionFieldItems (   $revision_id)
protected

{}

References SqlContentEntityStorage\buildQuery(), and SqlContentEntityStorage\mapFromStorageRecords().

Here is the call graph for this function:

doSaveFieldItems ( ContentEntityInterface  $entity,
array  $names = [] 
)
protected
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 DynamicallyFieldableEntityStorageSchemaInterface.

getBaseTable ( )

Gets the base table name.

Returns
string The table name.
getDataTable ( )

Gets the data table name.

Returns
string|false The table name or FALSE if it is not available.
getFieldStorageDefinitions ( )

Gets the base field definitions for a content entity type.

Returns
[] The array of base field definitions for the entity type, keyed by field name.

References Drupal\entityManager().

Here is the call graph for this function:

getFromStorage ( array  $ids = NULL)
protected

Gets entities from the storage.

Parameters
array | null$idsIf not empty, return entities that match these IDs. Return all entities when NULL.
Returns
[] Array of entities from the storage.

References SqlContentEntityStorage\buildQuery(), ContentEntityStorageBase\cleanIds(), and SqlContentEntityStorage\mapFromStorageRecords().

Referenced by SqlContentEntityStorage\doLoadMultiple().

Here is the call graph for this function:

Here is the caller graph for this function:

getQueryServiceName ( )
protected

{}

getRevisionDataTable ( )

Gets the revision data table name.

Returns
string|false The table name or FALSE if it is not available.
getRevisionTable ( )

Gets the revision table name.

Returns
string|false The table name or FALSE if it is not available.
getStorageSchema ( )
protected

Gets the entity type's storage schema object.

Returns
The schema object.

References Drupal\database(), and Drupal\entityManager().

Here is the call graph for this function:

getTableMapping ( array  $storage_definitions = NULL)

{Gets a table mapping for the entity's SQL tables.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface[]$storage_definitions (optional) An array of field storage definitions to be used to compute the table mapping. Defaults to the ones provided by the entity manager.
Returns
A table mapping object for the entity's tables.
}

Implements SqlEntityStorageInterface.

References Drupal\entityManager(), and FieldStorageDefinitionInterface\isRevisionable().

Referenced by SqlContentEntityStorage\buildQuery(), SqlContentEntityStorage\doSaveFieldItems(), and SqlContentEntityStorage\loadFromSharedTables().

Here is the call graph for this function:

Here is the caller graph for this function:

has (   $id,
EntityInterface  $entity 
)
protected

{}

References EntityInterface\isNew().

Here is the call graph for this function:

initTableLayout ( )
protected

Initializes table name variables.

Referenced by SqlContentEntityStorage\__construct(), and SqlContentEntityStorage\setEntityType().

Here is the caller graph for this function:

isColumnSerial (   $table_name,
  $schema_name 
)
protected

Checks whether a field column should be treated as serial.

Parameters
$table_nameThe name of the table the field column belongs to.
$schema_nameThe schema name of the field column.
Returns
bool TRUE if the column is serial, FALSE otherwise.
See Also
::processBaseTable()
::processRevisionTable()
loadFromDedicatedTables ( array &  $values,
  $load_from_revision 
)
protected

Loads values of fields stored in dedicated tables for a group of entities.

Parameters
array&$valuesAn array of values keyed by entity ID.
bool$load_from_revision(optional) Flag to indicate whether revisions should be loaded or not, defaults to FALSE.

Referenced by SqlContentEntityStorage\mapFromStorageRecords().

Here is the caller graph for this function:

loadFromSharedTables ( array &  $values,
array &  $translations 
)
protected

Loads values for fields stored in the shared data tables.

Parameters
array&$valuesAssociative array of entities values, keyed on the entity ID.
array&$translationsList of translations, keyed on the entity ID.

References Drupal\database(), SqlContentEntityStorage\getTableMapping(), and LanguageInterface\LANGCODE_DEFAULT.

Referenced by SqlContentEntityStorage\mapFromStorageRecords().

Here is the call graph for this function:

Here is the caller graph for this function:

mapFromStorageRecords ( array  $records,
  $load_from_revision = FALSE 
)
protected

Maps from storage records to entity objects, and attaches fields.

Parameters
array$recordsAssociative array of query results, keyed on the entity ID.
bool$load_from_revisionFlag to indicate whether revisions should be loaded or not.
Returns
array An array of entity objects implementing the EntityInterface.

References LanguageInterface\LANGCODE_DEFAULT, SqlContentEntityStorage\loadFromDedicatedTables(), and SqlContentEntityStorage\loadFromSharedTables().

Referenced by SqlContentEntityStorage\doLoadRevisionFieldItems(), and SqlContentEntityStorage\getFromStorage().

Here is the call graph for this function:

Here is the caller graph for this function:

mapToDataStorageRecord ( EntityInterface  $entity,
  $table_name = NULL 
)
protected

Maps from an entity object to the storage record of the field data.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity object.
string$table_name(optional) The table name to map records to. Defaults to the data table.
Returns
The record to store.
mapToStorageRecord ( ContentEntityInterface  $entity,
  $table_name = NULL 
)
protected

Maps from an entity object to the storage record.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity object.
string$table_name(optional) The table name to map records to. Defaults to the base table.
Returns
The record to store.

References drupal_schema_get_field_value().

Referenced by SqlContentEntityStorage\doSaveFieldItems().

Here is the call graph for this function:

Here is the caller graph for this function:

onBundleCreate (   $bundle,
  $entity_type_id 
)

{Reacts to a bundle being created.

Parameters
string$bundleThe name of the bundle created.
string$entity_type_idThe entity type to which the bundle is bound; e.g. 'node' or 'user'.
}

Implements EntityBundleListenerInterface.

onBundleDelete (   $bundle,
  $entity_type_id 
)

{Reacts to a bundle being deleted.This method runs before fields are deleted.

Parameters
string$bundleThe name of the bundle being deleted.
string$entity_type_idThe entity type to which the bundle is bound; e.g. 'node' or 'user'.
}

Implements EntityBundleListenerInterface.

onEntityTypeCreate ( EntityTypeInterface  $entity_type)

{Reacts to the creation of the entity type.

Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe entity type being created.
}

Implements EntityTypeListenerInterface.

onEntityTypeDelete ( EntityTypeInterface  $entity_type)

{Reacts to the deletion of the entity type.

Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe entity type being deleted.
}

Implements EntityTypeListenerInterface.

onEntityTypeUpdate ( EntityTypeInterface  $entity_type,
EntityTypeInterface  $original 
)

{Reacts to the update of the entity type.

Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe updated entity type definition.
\Drupal\Core\Entity\EntityTypeInterface$originalThe original entity type definition.
}

Implements EntityTypeListenerInterface.

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.

References FieldDefinitionInterface\getFieldStorageDefinition(), and FieldDefinitionInterface\getTargetBundle().

Here is the call graph for this function:

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.

purgeFieldItems ( ContentEntityInterface  $entity,
FieldDefinitionInterface  $field_definition 
)
protected

{}

References FieldDefinitionInterface\getFieldStorageDefinition(), RevisionableInterface\getRevisionId(), and EntityInterface\id().

Here is the call graph for this function:

readFieldItemsToPurge ( FieldDefinitionInterface  $field_definition,
  $batch_size 
)
protected

{}

References FieldDefinitionInterface\getFieldStorageDefinition(), FieldDefinitionInterface\getName(), FieldDefinitionInterface\getTargetBundle(), and Drupal\typedDataManager().

Here is the call graph for this function:

requiresEntityDataMigration ( EntityTypeInterface  $entity_type,
EntityTypeInterface  $original 
)

{Checks if existing data would be lost if the schema changes were applied.If there are no schema changes needed, then no data needs to be migrated, but it is not the responsibility of this function to recheck what requiresEntityStorageSchemaChanges() checks. Rather, the meaning of what this function returns when requiresEntityStorageSchemaChanges() returns FALSE is undefined. Callers are expected to only call this function when requiresEntityStorageSchemaChanges() is TRUE.This function can return FALSE if any of these conditions apply:

  • There are no existing entities for the entity type.
  • There are existing entities, but the schema changes can be applied without losing their data (e.g., if the schema changes can be performed by altering tables rather than dropping and recreating them).
  • The only entity data that would be lost are ones that are not valid for the new definition (e.g., if changing an entity type from revisionable to non-revisionable, then it's okay to drop data for the non-default revision).
When this function returns FALSE, site administrators will be unable to perform an automated update, and will instead need to perform a site migration or invoke some custom update process.
Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe updated entity type definition.
\Drupal\Core\Entity\EntityTypeInterface$originalThe original entity type definition.
Returns
bool TRUE if data migration is required, FALSE otherwise.
See Also
self::requiresEntityStorageSchemaChanges()
}

Implements EntityStorageSchemaInterface.

requiresEntityStorageSchemaChanges ( EntityTypeInterface  $entity_type,
EntityTypeInterface  $original 
)

{Checks if the changes to the entity type requires storage schema changes.

Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe updated entity type definition.
\Drupal\Core\Entity\EntityTypeInterface$originalThe original entity type definition.
Returns
bool TRUE if storage schema changes are required, FALSE otherwise.
}

Implements EntityStorageSchemaInterface.

requiresFieldDataMigration ( FieldStorageDefinitionInterface  $storage_definition,
FieldStorageDefinitionInterface  $original 
)

{Checks if existing data would be lost if the schema changes were applied.If there are no schema changes needed, then no data needs to be migrated, but it is not the responsibility of this function to recheck what requiresFieldStorageSchemaChanges() checks. Rather, the meaning of what this function returns when requiresFieldStorageSchemaChanges() returns FALSE is undefined. Callers are expected to only call this function when requiresFieldStorageSchemaChanges() is TRUE.This function can return FALSE if any of these conditions apply:

  • There are no existing entities for the entity type to which this field is attached.
  • There are existing entities, but none with existing values for this field.
  • There are existing field values, but the schema changes can be applied without losing them (e.g., if the schema changes can be performed by altering tables rather than dropping and recreating them).
  • The only field values that would be lost are ones that are not valid for the new definition (e.g., if changing a field from revisionable to non-revisionable, then it's okay to drop data for the non-default revision).
When this function returns FALSE, site administrators will be unable to perform an automated update, and will instead need to perform a site migration or invoke some custom update process.
Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe updated field storage definition.
\Drupal\Core\Field\FieldStorageDefinitionInterface$originalThe original field storage definition.
Returns
bool TRUE if data migration is required, FALSE otherwise.
See Also
self::requiresFieldStorageSchemaChanges()
}

Implements DynamicallyFieldableEntityStorageSchemaInterface.

requiresFieldStorageSchemaChanges ( FieldStorageDefinitionInterface  $storage_definition,
FieldStorageDefinitionInterface  $original 
)

{Checks if the changes to the storage definition requires schema changes.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe updated field storage definition.
\Drupal\Core\Field\FieldStorageDefinitionInterface$originalThe original field storage definition.
Returns
bool TRUE if storage schema changes are required, FALSE otherwise.
}

Implements DynamicallyFieldableEntityStorageSchemaInterface.

save ( EntityInterface  $entity)

{Saves the entity permanently.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity to save.
Returns
SAVED_NEW or SAVED_UPDATED is returned depending on the operation performed.
Exceptions
\Drupal\Core\Entity\EntityStorageExceptionIn case of failures, an exception is thrown.
}

Implements EntityStorageInterface.

References Drupal\database().

Here is the call graph for this function:

saveRevision ( ContentEntityInterface  $entity)
protected

Saves an entity revision.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity object.
Returns
int The revision id.

References TranslatableInterface\getUntranslated(), RevisionableInterface\isNewRevision(), and RevisionableInterface\preSaveRevision().

Referenced by SqlContentEntityStorage\doSaveFieldItems().

Here is the call graph for this function:

Here is the caller graph for this function:

saveToDedicatedTables ( ContentEntityInterface  $entity,
  $update = TRUE,
  $names = array() 
)
protected

Saves values of fields that use dedicated tables.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity.
bool$updateTRUE if the entity is being updated, FALSE if it is being inserted.
string[]$names (optional) The names of the fields to be stored. Defaults to all the available fields.

References EntityInterface\bundle(), EntityInterface\getEntityTypeId(), RevisionableInterface\getRevisionId(), TranslatableInterface\getTranslation(), TranslatableInterface\getTranslationLanguages(), TranslatableInterface\getUntranslated(), EntityInterface\id(), RevisionableInterface\isDefaultRevision(), and RevisionableInterface\isNewRevision().

Here is the call graph for this function:

saveToSharedTables ( ContentEntityInterface  $entity,
  $table_name = NULL,
  $new_revision = NULL 
)
protected

Saves fields that use the shared tables.

Parameters
\Drupal\Core\Entity\ContentEntityInterface$entityThe entity object.
string$table_name(optional) The table name to save to. Defaults to the data table.
bool$new_revision(optional) Whether we are dealing with a new revision. By default fetches the information from the entity object.

References RevisionableInterface\getRevisionId(), TranslatableInterface\getTranslation(), TranslatableInterface\getTranslationLanguages(), EntityInterface\id(), and RevisionableInterface\isNewRevision().

Here is the call graph for this function:

setEntityType ( EntityTypeInterface  $entity_type)

Updates the wrapped entity type definition.

Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe update entity type.

References EntityTypeInterface\id(), and SqlContentEntityStorage\initTableLayout().

Here is the call graph for this function:

storageDefinitionIsDeleted ( FieldStorageDefinitionInterface  $storage_definition)
protected

Determines whether the passed field has been already deleted.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe field storage definition.
Returns
bool Whether the field has been already deleted.

References FieldStorageDefinitionInterface\getName().

Here is the call graph for this function:

wrapSchemaException ( callable  $callback)
protected

Wraps a database schema exception into an entity storage exception.

Parameters
callable$callbackThe callback to be executed.
Exceptions
\Drupal\Core\Entity\EntityStorageExceptionWhen a database schema exception is thrown.

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