public function EntityLastInstalledSchemaRepository::getLastInstalledFieldStorageDefinitions in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php \Drupal\Core\Entity\EntityLastInstalledSchemaRepository::getLastInstalledFieldStorageDefinitions()
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
\Drupal\Core\Field\FieldStorageDefinitionInterface[] The array of installed field storage definitions for the entity type, keyed by field name.
Overrides EntityLastInstalledSchemaRepositoryInterface::getLastInstalledFieldStorageDefinitions
See also
\Drupal\Core\Entity\EntityTypeListenerInterface
2 calls to EntityLastInstalledSchemaRepository::getLastInstalledFieldStorageDefinitions()
- EntityLastInstalledSchemaRepository::deleteLastInstalledFieldStorageDefinition in core/
lib/ Drupal/ Core/ Entity/ EntityLastInstalledSchemaRepository.php - Deletes the field storage definition from the application state.
- EntityLastInstalledSchemaRepository::setLastInstalledFieldStorageDefinition in core/
lib/ Drupal/ Core/ Entity/ EntityLastInstalledSchemaRepository.php - Stores the field storage definition in the application state.
File
- core/
lib/ Drupal/ Core/ Entity/ EntityLastInstalledSchemaRepository.php, line 120
Class
- EntityLastInstalledSchemaRepository
- Provides a repository for installed entity definitions.
Namespace
Drupal\Core\EntityCode
public function getLastInstalledFieldStorageDefinitions($entity_type_id) {
if ($cache = $this->cacheBackend
->get($entity_type_id . '.field_storage_definitions.installed')) {
return $cache->data;
}
$definitions = $this->keyValueFactory
->get('entity.definitions.installed')
->get($entity_type_id . '.field_storage_definitions', []);
$this->cacheBackend
->set($entity_type_id . '.field_storage_definitions.installed', $definitions, Cache::PERMANENT);
return $definitions;
}