You are here

public function EntityDefinitionUpdateManager::updateFieldableEntityType in Drupal 9

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

Applies any change performed to a fieldable entity type definition.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The updated entity type definition.

\Drupal\Core\Field\FieldStorageDefinitionInterface[] $field_storage_definitions: The updated field storage definitions, including possibly new ones.

array &$sandbox: (optional) A sandbox array provided by a hook_update_N() implementation or a Batch API callback. If the entity schema update requires a data migration, this parameter is mandatory. Defaults to NULL.

Overrides EntityDefinitionUpdateManagerInterface::updateFieldableEntityType

File

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

Class

EntityDefinitionUpdateManager
Manages entity definition updates.

Namespace

Drupal\Core\Entity

Code

public function updateFieldableEntityType(EntityTypeInterface $entity_type, array $field_storage_definitions, array &$sandbox = NULL) {
  $original = $this
    ->getEntityType($entity_type
    ->id());
  if ($this
    ->requiresEntityDataMigration($entity_type, $original) && $sandbox === NULL) {
    throw new \InvalidArgumentException('The entity schema update for the ' . $entity_type
      ->id() . ' entity type requires a data migration.');
  }
  $original_field_storage_definitions = $this->entityLastInstalledSchemaRepository
    ->getLastInstalledFieldStorageDefinitions($entity_type
    ->id());
  $this->entityTypeListener
    ->onFieldableEntityTypeUpdate($entity_type, $original, $field_storage_definitions, $original_field_storage_definitions, $sandbox);
  $this
    ->clearCachedDefinitions();
}