You are here

public function EntityDefinitionUpdateManager::installFieldStorageDefinition in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php \Drupal\Core\Entity\EntityDefinitionUpdateManager::installFieldStorageDefinition()

Installs a new field storage definition.

Parameters

string $name: The field storage definition name.

string $entity_type_id: The target entity type identifier.

string $provider: The name of the definition provider.

\Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition: The field storage definition.

Overrides EntityDefinitionUpdateManagerInterface::installFieldStorageDefinition

File

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

Class

EntityDefinitionUpdateManager
Manages entity definition updates.

Namespace

Drupal\Core\Entity

Code

public function installFieldStorageDefinition($name, $entity_type_id, $provider, FieldStorageDefinitionInterface $storage_definition) {

  // @todo Pass a mutable field definition interface when we have one. See
  //   https://www.drupal.org/node/2346329.
  if ($storage_definition instanceof BaseFieldDefinition) {
    $storage_definition
      ->setName($name)
      ->setTargetEntityTypeId($entity_type_id)
      ->setProvider($provider)
      ->setTargetBundle(NULL);
  }
  $this
    ->clearCachedDefinitions();
  $this->fieldStorageDefinitionListener
    ->onFieldStorageDefinitionCreate($storage_definition);
}