function EntityTypeListener::onFieldableEntityTypeCreate

Reacts to the creation of the fieldable entity type.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type being created.

\Drupal\Core\Field\FieldStorageDefinitionInterface[] $field_storage_definitions: The entity type's field storage definitions.

Overrides EntityTypeListenerInterface::onFieldableEntityTypeCreate

File

core/lib/Drupal/Core/Entity/EntityTypeListener.php, line 86

Class

EntityTypeListener
Reacts to entity type CRUD on behalf of the Entity system.

Namespace

Drupal\Core\Entity

Code

public function onFieldableEntityTypeCreate(EntityTypeInterface $entity_type, array $field_storage_definitions) {
  $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
    ->createHandlerInstance($entity_type->getStorageClass(), $entity_type);
  if ($storage instanceof EntityTypeListenerInterface) {
    $storage->onFieldableEntityTypeCreate($entity_type, $field_storage_definitions);
  }
  $this->entityLastInstalledSchemaRepository
    ->setLastInstalledDefinition($entity_type);
  if ($entity_type->entityClassImplements(FieldableEntityInterface::class)) {
    $this->entityLastInstalledSchemaRepository
      ->setLastInstalledFieldStorageDefinitions($entity_type_id, $field_storage_definitions);
  }
  $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.