You are here

public static function BaseFieldOverride::postDelete in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php \Drupal\Core\Field\Entity\BaseFieldOverride::postDelete()

Acts on deleted entities before the delete hook is invoked.

Used after the entities are deleted but before invoking the delete hook.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.

Overrides EntityBase::postDelete

File

core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php, line 211

Class

BaseFieldOverride
Defines the base field override entity.

Namespace

Drupal\Core\Field\Entity

Code

public static function postDelete(EntityStorageInterface $storage, array $field_overrides) {
  $entity_type_manager = \Drupal::entityTypeManager();

  // Clear the cache upfront, to refresh the results of getBundles().
  \Drupal::service('entity_field.manager')
    ->clearCachedFieldDefinitions();

  /** @var \Drupal\Core\Field\Entity\BaseFieldOverride $field_override */
  foreach ($field_overrides as $field_override) {

    // Inform the system that the field definition is being updated back to
    // its non-overridden state.
    // @todo This assumes that there isn't a non-config-based override that
    //   we're returning to, but that might not be the case:
    //   https://www.drupal.org/node/2321071.
    $entity_type_manager
      ->getStorage($field_override
      ->getTargetEntityTypeId())
      ->onFieldDefinitionUpdate($field_override
      ->getBaseFieldDefinition(), $field_override);
  }
}