function 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 71 
Class
- EntityDefinitionTestTrait
- Provides some test methods used to update existing entity definitions.
Namespace
Drupal\Tests\system\Functional\Entity\TraitsCode
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;
  }
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
