You are here

private function VarbaseEntityDefinitionUpdateManager::doEntityUpdate in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.8

Same name and namespace in other branches
  1. 8.6 src/Entity/VarbaseEntityDefinitionUpdateManager.php \Drupal\varbase\entity\VarbaseEntityDefinitionUpdateManager::doEntityUpdate()
  2. 8.7 src/Entity/VarbaseEntityDefinitionUpdateManager.php \Drupal\varbase\entity\VarbaseEntityDefinitionUpdateManager::doEntityUpdate()

Performs an entity type definition update.

Parameters

string $op: The operation to perform, either static::DEFINITION_CREATED or static::DEFINITION_UPDATED.

string $entity_type_id: The entity type ID.

1 call to VarbaseEntityDefinitionUpdateManager::doEntityUpdate()
VarbaseEntityDefinitionUpdateManager::applyUpdates in src/Entity/VarbaseEntityDefinitionUpdateManager.php
Applies all the detected valid changes.

File

src/Entity/VarbaseEntityDefinitionUpdateManager.php, line 161

Class

VarbaseEntityDefinitionUpdateManager
Varbase Entity Definition Update Manager.

Namespace

Drupal\varbase\entity

Code

private function doEntityUpdate($op, $entity_type_id) {
  $entity_type = $this->entityTypeManager
    ->getDefinition($entity_type_id);
  switch ($op) {
    case EntityDefinitionUpdateManagerInterface::DEFINITION_CREATED:
      $this->entityTypeListener
        ->onEntityTypeCreate($entity_type);
      break;
    case EntityDefinitionUpdateManagerInterface::DEFINITION_UPDATED:
      $original = $this->entityLastInstalledSchemaRepository
        ->getLastInstalledDefinition($entity_type_id);
      $storage = $this->entityTypeManager
        ->getStorage($entity_type
        ->id());
      if ($storage instanceof EntityStorageSchemaInterface && $storage
        ->requiresEntityDataMigration($entity_type, $original)) {
        throw new \InvalidArgumentException('The entity schema update for the ' . $entity_type
          ->id() . ' entity type requires a data migration.');
      }
      $field_storage_definitions = $this->entityFieldManager
        ->getFieldStorageDefinitions($entity_type_id);
      $original_field_Storage_definitions = $this->entityLastInstalledSchemaRepository
        ->getLastInstalledFieldStorageDefinitions($entity_type_id);
      $this->entityTypeListener
        ->onFieldableEntityTypeUpdate($entity_type, $original, $field_storage_definitions, $original_field_Storage_definitions);
      break;
  }
}