public function EntityLastInstalledSchemaRepository::getLastInstalledDefinition

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:

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');
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityLastInstalledSchemaRepository.php/function/EntityLastInstalledSchemaRepository::getLastInstalledDefinition/8.1.x