public function EntityTestDefinitionSubscriber::onEntityTypeUpdate in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/entity_test/src/EntityTestDefinitionSubscriber.php \Drupal\entity_test\EntityTestDefinitionSubscriber::onEntityTypeUpdate()
- 9 core/modules/system/tests/modules/entity_test/src/EntityTestDefinitionSubscriber.php \Drupal\entity_test\EntityTestDefinitionSubscriber::onEntityTypeUpdate()
Reacts to the update of the entity type.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The updated entity type definition.
\Drupal\Core\Entity\EntityTypeInterface $original: The original entity type definition.
Overrides EntityTypeEventSubscriberTrait::onEntityTypeUpdate
File
- core/
modules/ system/ tests/ modules/ entity_test/ src/ EntityTestDefinitionSubscriber.php, line 114
Class
- EntityTestDefinitionSubscriber
- Test entity type and field storage definition event subscriber.
Namespace
Drupal\entity_testCode
public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
$last_installed_definition = $this->entityLastInstalledSchemaRepository
->getLastInstalledDefinition($entity_type
->id());
if ((string) $last_installed_definition
->getLabel() === 'Updated entity test rev') {
$this
->storeDefinitionUpdate(EntityTypeEvents::UPDATE);
}
$this
->storeEvent(EntityTypeEvents::UPDATE);
// Retrieve the live entity type definition in order to warm the static
// cache and then insert the new entity type definition, so we can test that
// the cache doesn't get stale after the event has fired.
if ($this->updateLiveDefinitions) {
$this->entityTypeManager
->getDefinition($entity_type
->id());
$this->state
->set('entity_test_rev.entity_type', $entity_type);
}
}