You are here

protected function EntityDefinitionTestTrait::doEntityUpdate in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait::doEntityUpdate()
  2. 9 core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php \Drupal\Tests\system\Functional\Entity\Traits\EntityDefinitionTestTrait::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 EntityDefinitionTestTrait::doEntityUpdate()
EntityDefinitionTestTrait::applyEntityUpdates in core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php
Applies all the detected valid changes.

File

core/modules/system/tests/src/Functional/Entity/Traits/EntityDefinitionTestTrait.php, line 69

Class

EntityDefinitionTestTrait
Provides some test methods used to update existing entity definitions.

Namespace

Drupal\Tests\system\Functional\Entity\Traits

Code

protected function doEntityUpdate($op, $entity_type_id) {
  $entity_type = \Drupal::entityTypeManager()
    ->getDefinition($entity_type_id);
  $field_storage_definitions = \Drupal::service('entity_field.manager')
    ->getFieldStorageDefinitions($entity_type_id);
  switch ($op) {
    case EntityDefinitionUpdateManagerInterface::DEFINITION_CREATED:
      \Drupal::service('entity_type.listener')
        ->onEntityTypeCreate($entity_type);
      break;
    case EntityDefinitionUpdateManagerInterface::DEFINITION_UPDATED:
      $original = \Drupal::service('entity.last_installed_schema.repository')
        ->getLastInstalledDefinition($entity_type_id);
      $original_field_storage_definitions = \Drupal::service('entity.last_installed_schema.repository')
        ->getLastInstalledFieldStorageDefinitions($entity_type_id);
      \Drupal::service('entity_type.listener')
        ->onFieldableEntityTypeUpdate($entity_type, $original, $field_storage_definitions, $original_field_storage_definitions);
      break;
  }
}