You are here

public static function ImageAPIOptimizePipeline::postDelete in Image Optimize (or ImageAPI Optimize) 4.x

Same name and namespace in other branches
  1. 8.3 src/Entity/ImageAPIOptimizePipeline.php \Drupal\imageapi_optimize\Entity\ImageAPIOptimizePipeline::postDelete()
  2. 8.2 src/Entity/ImageAPIOptimizePipeline.php \Drupal\imageapi_optimize\Entity\ImageAPIOptimizePipeline::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

src/Entity/ImageAPIOptimizePipeline.php, line 117

Class

ImageAPIOptimizePipeline
Defines an image optimize pipeline configuration entity.

Namespace

Drupal\imageapi_optimize\Entity

Code

public static function postDelete(EntityStorageInterface $storage, array $entities) {
  parent::postDelete($storage, $entities);

  /** @var \Drupal\imageapi_optimize\ImageAPIOptimizePipelineInterface[] $entities */
  foreach ($entities as $pipeline) {

    // Flush cached media for the deleted pipeline.
    $pipeline
      ->flush();

    // Clear the replacement ID, if one has been previously stored.

    /** @var \Drupal\imageapi_optimize\ImageAPIOptimizePipelineStorageInterface $storage */
    $storage
      ->clearReplacementId($pipeline
      ->id());
  }
}