function EntityTypeListener::onEntityTypeCreate
Same name in other branches
- 9 core/lib/Drupal/Core/Entity/EntityTypeListener.php \Drupal\Core\Entity\EntityTypeListener::onEntityTypeCreate()
- 8.9.x core/lib/Drupal/Core/Entity/EntityTypeListener.php \Drupal\Core\Entity\EntityTypeListener::onEntityTypeCreate()
- 11.x core/lib/Drupal/Core/Entity/EntityTypeListener.php \Drupal\Core\Entity\EntityTypeListener::onEntityTypeCreate()
File
-
core/
lib/ Drupal/ Core/ Entity/ EntityTypeListener.php, line 64
Class
- EntityTypeListener
- Reacts to entity type CRUD on behalf of the Entity system.
Namespace
Drupal\Core\EntityCode
public function onEntityTypeCreate(EntityTypeInterface $entity_type) {
$entity_type_id = $entity_type->id();
// @todo Forward this to all interested handlers, not only storage, once
// iterating handlers is possible: https://www.drupal.org/node/2332857.
$storage = $this->entityTypeManager
->getStorage($entity_type_id);
if ($storage instanceof EntityTypeListenerInterface) {
$storage->onEntityTypeCreate($entity_type);
}
$this->entityLastInstalledSchemaRepository
->setLastInstalledDefinition($entity_type);
if ($entity_type->entityClassImplements(FieldableEntityInterface::class)) {
$this->entityLastInstalledSchemaRepository
->setLastInstalledFieldStorageDefinitions($entity_type_id, $this->entityFieldManager
->getFieldStorageDefinitions($entity_type_id));
}
$this->eventDispatcher
->dispatch(new EntityTypeEvent($entity_type), EntityTypeEvents::CREATE);
$this->clearCachedDefinitions();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.