public function EntityTypeListener::onEntityTypeUpdate in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Entity/EntityTypeListener.php \Drupal\Core\Entity\EntityTypeListener::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 EntityTypeListenerInterface::onEntityTypeUpdate
File
- core/
lib/ Drupal/ Core/ Entity/ EntityTypeListener.php, line 108
Class
- EntityTypeListener
- Reacts to entity type CRUD on behalf of the Entity system.
Namespace
Drupal\Core\EntityCode
public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
// An entity type can be updated even when its live (in-code) definition has
// been removed from the codebase, so we need to instantiate a custom
// storage handler that uses the passed-in entity type definition.
$storage = $this->entityTypeManager
->createHandlerInstance($entity_type
->getStorageClass(), $entity_type);
// @todo Forward this to all interested handlers, not only storage, once
// iterating handlers is possible: https://www.drupal.org/node/2332857.
if ($storage instanceof EntityTypeListenerInterface) {
$storage
->onEntityTypeUpdate($entity_type, $original);
}
$this->entityLastInstalledSchemaRepository
->setLastInstalledDefinition($entity_type);
$this->eventDispatcher
->dispatch(EntityTypeEvents::UPDATE, new EntityTypeEvent($entity_type, $original));
$this
->clearCachedDefinitions();
}