public EntityLastInstalledSchemaRepository::getLastInstalledDefinition($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
\Drupal\Core\Entity\EntityTypeInterface|null The installed entity type definition, or NULL if the entity type has not yet been installed via onEntityTypeCreate().
Overrides EntityLastInstalledSchemaRepositoryInterface::getLastInstalledDefinition
See also
\Drupal\Core\Entity\EntityTypeListenerInterface
File
- core/lib/Drupal/Core/Entity/EntityLastInstalledSchemaRepository.php, line 33
Class
- EntityLastInstalledSchemaRepository
- Provides a repository for installed entity definitions.
Namespace
Drupal\Core\Entity
Code
public function getLastInstalledDefinition($entity_type_id) { return $this->keyValueFactory->get('entity.definitions.installed')->get($entity_type_id . '.entity_type'); }
Please login to continue.