Drupal 8  8.0.2
EntityDefinitionUpdateManager Class Reference
Inheritance diagram for EntityDefinitionUpdateManager:

Public Member Functions

 __construct (EntityManagerInterface $entity_manager)
 
 needsUpdates ()
 
 getChangeSummary ()
 
 applyUpdates ()
 
 getEntityType ($entity_type_id)
 
 installEntityType (EntityTypeInterface $entity_type)
 
 updateEntityType (EntityTypeInterface $entity_type)
 
 uninstallEntityType (EntityTypeInterface $entity_type)
 
 installFieldStorageDefinition ($name, $entity_type_id, $provider, FieldStorageDefinitionInterface $storage_definition)
 
 getFieldStorageDefinition ($name, $entity_type_id)
 
 updateFieldStorageDefinition (FieldStorageDefinitionInterface $storage_definition)
 
 uninstallFieldStorageDefinition (FieldStorageDefinitionInterface $storage_definition)
 

Protected Member Functions

 doEntityUpdate ($op, $entity_type_id)
 
 doFieldUpdate ($op, $storage_definition=NULL, $original_storage_definition=NULL)
 
 getChangeList ()
 
 requiresEntityStorageSchemaChanges (EntityTypeInterface $entity_type, EntityTypeInterface $original)
 
 requiresFieldStorageSchemaChanges (FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original)
 

Protected Attributes

 $entityManager
 

Additional Inherited Members

- Data Fields inherited from EntityDefinitionUpdateManagerInterface
const DEFINITION_CREATED = 1
 
const DEFINITION_UPDATED = 2
 
const DEFINITION_DELETED = 3
 

Detailed Description

Manages entity definition updates.

Constructor & Destructor Documentation

__construct ( EntityManagerInterface  $entity_manager)

Constructs a new EntityDefinitionUpdateManager.

Parameters
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager.

References Drupal\entityManager().

Here is the call graph for this function:

Member Function Documentation

applyUpdates ( )

{Applies all the detected valid changes.Use this with care, as it will apply updates for any module, which will lead to unpredictable results.

Exceptions
\Drupal\Core\Entity\EntityStorageExceptionThis exception is thrown if a change cannot be applied without unacceptable data loss. In such a case, the site administrator needs to apply some other process, such as a custom update function or a migration via the Migrate module.
}

Implements EntityDefinitionUpdateManagerInterface.

References EntityDefinitionUpdateManager\doEntityUpdate(), EntityDefinitionUpdateManager\doFieldUpdate(), Drupal\entityManager(), and EntityDefinitionUpdateManager\getChangeList().

Here is the call graph for this function:

doEntityUpdate (   $op,
  $entity_type_id 
)
protected

Performs an entity type definition update.

Parameters
string$opThe operation to perform, either static::DEFINITION_CREATED or static::DEFINITION_UPDATED.
string$entity_type_idThe entity type ID.

References Drupal\entityManager().

Referenced by EntityDefinitionUpdateManager\applyUpdates().

Here is the call graph for this function:

Here is the caller graph for this function:

doFieldUpdate (   $op,
  $storage_definition = NULL,
  $original_storage_definition = NULL 
)
protected

Performs a field storage definition update.

Parameters
string$opThe operation to perform, possible values are static::DEFINITION_CREATED, static::DEFINITION_UPDATED or static::DEFINITION_DELETED.
array | null$storage_definitionThe new field storage definition.
array | null$original_storage_definitionThe original field storage definition.

References Drupal\entityManager().

Referenced by EntityDefinitionUpdateManager\applyUpdates().

Here is the call graph for this function:

Here is the caller graph for this function:

getChangeList ( )
protected

Gets a list of changes to entity type and field storage definitions.

Returns
array An associative array keyed by entity type id of change descriptors. Every entry is an associative array with the following optional keys:
  • entity_type: a scalar having only the DEFINITION_UPDATED value.
  • field_storage_definitions: an associative array keyed by field name of scalars having one value among:
    • DEFINITION_CREATED
    • DEFINITION_UPDATED
    • DEFINITION_DELETED

References Drupal\entityManager(), EntityDefinitionUpdateManager\requiresEntityStorageSchemaChanges(), and EntityDefinitionUpdateManager\requiresFieldStorageSchemaChanges().

Referenced by EntityDefinitionUpdateManager\applyUpdates(), EntityDefinitionUpdateManager\getChangeSummary(), and EntityDefinitionUpdateManager\needsUpdates().

Here is the call graph for this function:

Here is the caller graph for this function:

getChangeSummary ( )

{Gets a human readable summary of the detected changes.

Returns
array An associative array keyed by entity type id. Each entry is an array of human-readable strings, each describing a change.
}

Implements EntityDefinitionUpdateManagerInterface.

References Drupal\entityManager(), EntityDefinitionUpdateManager\getChangeList(), and t().

Here is the call graph for this function:

getEntityType (   $entity_type_id)

{Returns an entity type definition ready to be manipulated.When needing to apply updates to existing entity type definitions, this method should always be used to retrieve a definition ready to be manipulated.

Parameters
string$entity_type_idThe entity type identifier.
Returns
The entity type definition.
}

Implements EntityDefinitionUpdateManagerInterface.

References Drupal\entityManager().

Referenced by EntityDefinitionUpdateManager\updateEntityType().

Here is the call graph for this function:

Here is the caller graph for this function:

getFieldStorageDefinition (   $name,
  $entity_type_id 
)

{Returns a field storage definition ready to be manipulated.When needing to apply updates to existing field storage definitions, this method should always be used to retrieve a storage definition ready to be manipulated.

Parameters
string$nameThe field name.
string$entity_type_idThe entity type identifier.
Returns
The field storage definition.
Todo:
Make this return a mutable storage definition interface when we have one. See https://www.drupal.org/node/2346329.
}

Implements EntityDefinitionUpdateManagerInterface.

References Drupal\entityManager().

Referenced by EntityDefinitionUpdateManager\updateFieldStorageDefinition().

Here is the call graph for this function:

Here is the caller graph for this function:

installEntityType ( EntityTypeInterface  $entity_type)

{Installs a new entity type definition.

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

Implements EntityDefinitionUpdateManagerInterface.

References Drupal\entityManager().

Here is the call graph for this function:

installFieldStorageDefinition (   $name,
  $entity_type_id,
  $provider,
FieldStorageDefinitionInterface  $storage_definition 
)

{Installs a new field storage definition.

Parameters
string$nameThe field storage definition name.
string$entity_type_idThe target entity type identifier.
string$providerThe name of the definition provider.
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe field storage definition.
}

Implements EntityDefinitionUpdateManagerInterface.

References Drupal\entityManager().

Here is the call graph for this function:

needsUpdates ( )

{Checks if there are any definition updates that need to be applied.

Returns
bool TRUE if updates are needed.
}

Implements EntityDefinitionUpdateManagerInterface.

References EntityDefinitionUpdateManager\getChangeList().

Here is the call graph for this function:

requiresEntityStorageSchemaChanges ( EntityTypeInterface  $entity_type,
EntityTypeInterface  $original 
)
protected

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.

References Drupal\entityManager(), and EntityTypeInterface\id().

Referenced by EntityDefinitionUpdateManager\getChangeList().

Here is the call graph for this function:

Here is the caller graph for this function:

requiresFieldStorageSchemaChanges ( FieldStorageDefinitionInterface  $storage_definition,
FieldStorageDefinitionInterface  $original 
)
protected

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.

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

Referenced by EntityDefinitionUpdateManager\getChangeList().

Here is the call graph for this function:

Here is the caller graph for this function:

uninstallEntityType ( EntityTypeInterface  $entity_type)

{Uninstalls an entity type definition.

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

Implements EntityDefinitionUpdateManagerInterface.

References Drupal\entityManager().

Here is the call graph for this function:

uninstallFieldStorageDefinition ( FieldStorageDefinitionInterface  $storage_definition)

{Uninstalls a field storage definition.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe field storage definition.
}

Implements EntityDefinitionUpdateManagerInterface.

References Drupal\entityManager().

Here is the call graph for this function:

updateEntityType ( EntityTypeInterface  $entity_type)

{Applies any change performed to the passed entity type definition.

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

Implements EntityDefinitionUpdateManagerInterface.

References Drupal\entityManager(), EntityDefinitionUpdateManager\getEntityType(), and EntityTypeInterface\id().

Here is the call graph for this function:

updateFieldStorageDefinition ( FieldStorageDefinitionInterface  $storage_definition)

{Applies any change performed to the passed field storage definition.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$storage_definitionThe field storage definition.
}

Implements EntityDefinitionUpdateManagerInterface.

References Drupal\entityManager(), EntityDefinitionUpdateManager\getFieldStorageDefinition(), FieldStorageDefinitionInterface\getName(), and FieldStorageDefinitionInterface\getTargetEntityTypeId().

Here is the call graph for this function:


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