You are here

public function ImageAPIOptimizePipeline::flush in Image Optimize (or ImageAPI Optimize) 8.2

Same name and namespace in other branches
  1. 8.3 src/Entity/ImageAPIOptimizePipeline.php \Drupal\imageapi_optimize\Entity\ImageAPIOptimizePipeline::flush()
  2. 4.x src/Entity/ImageAPIOptimizePipeline.php \Drupal\imageapi_optimize\Entity\ImageAPIOptimizePipeline::flush()

Flushes cached media for this pipeline.

Return value

$this

Overrides ImageAPIOptimizePipelineInterface::flush

1 call to ImageAPIOptimizePipeline::flush()
ImageAPIOptimizePipeline::postSave in src/Entity/ImageAPIOptimizePipeline.php
Acts on a saved entity before the insert or update hook is invoked.

File

src/Entity/ImageAPIOptimizePipeline.php, line 145

Class

ImageAPIOptimizePipeline
Defines an image optimize pipeline configuration entity.

Namespace

Drupal\imageapi_optimize\Entity

Code

public function flush() {

  // Get all image optimize pipelines and if they use this pipeline, flush it.
  $style_storage = $this
    ->entityTypeManager()
    ->getStorage('image_style');
  foreach ($style_storage
    ->loadMultiple() as $style) {

    /** @var ImageStyleWithPipeline $style */
    if ($style
      ->hasPipeline() && $style
      ->getPipelineEntity()
      ->id() == $this
      ->id()) {
      $style
        ->flush();
    }
  }

  // Let other modules update as necessary on flush.
  $module_handler = \Drupal::moduleHandler();
  $module_handler
    ->invokeAll('imageapi_optimize_pipeline_flush', [
    $this,
  ]);
  Cache::invalidateTags($this
    ->getCacheTagsToInvalidate());
  return $this;
}