You are here

public static function BaseFieldOverride::postDelete in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 Entity::postDelete

File

core/lib/Drupal/Core/Field/Entity/BaseFieldOverride.php, line 203
Contains \Drupal\Core\Field\Entity\BaseFieldOverride.

Class

BaseFieldOverride
Defines the base field override entity.

Namespace

Drupal\Core\Field\Entity

Code

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

  // Clear the cache upfront, to refresh the results of getBundles().
  $entity_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_manager
      ->getStorage($field_override
      ->getTargetEntityTypeId())
      ->onFieldDefinitionUpdate($field_override
      ->getBaseFieldDefinition(), $field_override);
  }
}