class EntityLastInstalledSchemaRepository implements EntityLastInstalledSchemaRepositoryInterface (View source)

Provides a repository for installed entity definitions.

Properties

protected KeyValueFactoryInterface $keyValueFactory

The key-value factory.

protected CacheBackendInterface $cacheBackend

The cache backend.

protected array|null $entityTypeDefinitions

The loaded installed entity type definitions.

Methods

__construct(KeyValueFactoryInterface $key_value_factory, CacheBackendInterface $cache = NULL)

Constructs a new EntityLastInstalledSchemaRepository.

getLastInstalledDefinition(string $entity_type_id)

Gets the entity type definition in its most recently installed state.

getLastInstalledDefinitions()

Gets the entity type definitions in their most recently installed state.

$this
setLastInstalledDefinition(EntityTypeInterface $entity_type)

Stores the entity type definition in the application state.

$this
deleteLastInstalledDefinition(string $entity_type_id)

Deletes the entity type definition from the application state.

getLastInstalledFieldStorageDefinitions(string $entity_type_id)

Gets the entity type's most recently installed field storage definitions.

setLastInstalledFieldStorageDefinitions(string $entity_type_id, array $storage_definitions)

Stores the entity type's field storage definitions in the application state.

setLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition)

Stores the field storage definition in the application state.

deleteLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition)

Deletes the field storage definition from the application state.

Details

__construct(KeyValueFactoryInterface $key_value_factory, CacheBackendInterface $cache = NULL)

Constructs a new EntityLastInstalledSchemaRepository.

Parameters

KeyValueFactoryInterface $key_value_factory

The key-value factory.

CacheBackendInterface $cache

The cache backend.

EntityTypeInterface|null getLastInstalledDefinition(string $entity_type_id)

Gets the entity type definition in its most recently installed state.

During the application lifetime, entity type definitions can change. For example, updated code can be deployed. The getDefinition() method will always return the definition as determined by the current codebase. This method, however, returns what the definition was when the last time that one of the \Drupal\Core\Entity\EntityTypeListenerInterface events was last fired and completed successfully. In other words, the definition that the entity type's handlers have incorporated into the application state. For example, if the entity type's storage handler is SQL-based, the definition for which database tables were created.

Application management code can check if getDefinition() differs from getLastInstalledDefinition() and decide whether to:

  • Invoke the appropriate \Drupal\Core\Entity\EntityTypeListenerInterface event so that handlers react to the new definition.
  • Raise a warning that the application state is incompatible with the codebase.
  • Perform some other action.

Parameters

string $entity_type_id

The entity type ID.

Return Value

EntityTypeInterface|null

The installed entity type definition, or NULL if the entity type has not yet been installed via onEntityTypeCreate().

EntityTypeInterface[] getLastInstalledDefinitions()

Gets the entity type definitions in their most recently installed state.

During the application lifetime, entity type definitions can change. For example, updated code can be deployed. The \Drupal\Core\Entity\EntityTypeManagerInterface::getDefinitions() method will always return the definitions as determined by the current codebase. This method returns the definitions from the last time that a \Drupal\Core\Entity\EntityTypeListener event was completed. In other words, the definitions that the entity type's handlers have incorporated into the application state. For example, if the entity type's storage handler is SQL-based, the definition for which database tables were created.

Application management code can check if \Drupal\Core\Entity\EntityTypeManagerInterface::getDefinitions() differs from getLastInstalledDefinitions() and decide whether to:

  • Invoke the appropriate \Drupal\Core\Entity\EntityTypeListenerInterface event so that handlers react to the new definitions.
  • Raise a warning that the application state is incompatible with the codebase.
  • Perform some other action.

Return Value

EntityTypeInterface[]

An array containing the installed definition for all entity types, keyed by the entity type ID.

$this setLastInstalledDefinition(EntityTypeInterface $entity_type)

Stores the entity type definition in the application state.

Parameters

EntityTypeInterface $entity_type

The entity type definition.

Return Value

$this

$this deleteLastInstalledDefinition(string $entity_type_id)

Deletes the entity type definition from the application state.

Parameters

string $entity_type_id

The entity type definition identifier.

Return Value

$this

FieldStorageDefinitionInterface[] getLastInstalledFieldStorageDefinitions(string $entity_type_id)

Gets the entity type's most recently installed field storage definitions.

During the application lifetime, field storage definitions can change. For example, updated code can be deployed. The getFieldStorageDefinitions() method will always return the definitions as determined by the current codebase. This method, however, returns what the definitions were when the last time that one of the \Drupal\Core\Field\FieldStorageDefinitionListenerInterface events was last fired and completed successfully. In other words, the definitions that the entity type's handlers have incorporated into the application state. For example, if the entity type's storage handler is SQL-based, the definitions for which database tables were created.

Application management code can check if getFieldStorageDefinitions() differs from getLastInstalledFieldStorageDefinitions() and decide whether to:

  • Invoke the appropriate \Drupal\Core\Field\FieldStorageDefinitionListenerInterface events so that handlers react to the new definitions.
  • Raise a warning that the application state is incompatible with the codebase.
  • Perform some other action.

Parameters

string $entity_type_id

The entity type ID.

Return Value

FieldStorageDefinitionInterface[]

The array of installed field storage definitions for the entity type, keyed by field name.

setLastInstalledFieldStorageDefinitions(string $entity_type_id, array $storage_definitions)

Stores the entity type's field storage definitions in the application state.

Parameters

string $entity_type_id

The entity type identifier.

array $storage_definitions

An array of field storage definitions.

setLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition)

Stores the field storage definition in the application state.

Parameters

FieldStorageDefinitionInterface $storage_definition

The field storage definition.

deleteLastInstalledFieldStorageDefinition(FieldStorageDefinitionInterface $storage_definition)

Deletes the field storage definition from the application state.

Parameters

FieldStorageDefinitionInterface $storage_definition

The field storage definition.