function EntityDefinitionUpdateManager::installFieldableEntityType

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php \Drupal\Core\Entity\EntityDefinitionUpdateManager::installFieldableEntityType()
  2. 10 core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php \Drupal\Core\Entity\EntityDefinitionUpdateManager::installFieldableEntityType()
  3. 11.x core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php \Drupal\Core\Entity\EntityDefinitionUpdateManager::installFieldableEntityType()

Overrides EntityDefinitionUpdateManagerInterface::installFieldableEntityType

File

core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php, line 173

Class

EntityDefinitionUpdateManager
Manages entity definition updates.

Namespace

Drupal\Core\Entity

Code

public function installFieldableEntityType(EntityTypeInterface $entity_type, array $field_storage_definitions) {
    $this->clearCachedDefinitions();
    foreach ($field_storage_definitions as $name => $field_storage_definition) {
        if ($field_storage_definition instanceof BaseFieldDefinition) {
            $field_storage_definition->setName($name)
                ->setTargetEntityTypeId($entity_type->id())
                ->setProvider($entity_type->getProvider())
                ->setTargetBundle(NULL);
        }
    }
    $this->entityTypeListener
        ->onFieldableEntityTypeCreate($entity_type, $field_storage_definitions);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.