You are here

public function TextimageFactory::flushStyle in Textimage 8.4

Same name and namespace in other branches
  1. 8.3 src/TextimageFactory.php \Drupal\textimage\TextimageFactory::flushStyle()

Flushes Textimage style data.

Clears immediate cache and all the image files associated.

Parameters

\Drupal\image\ImageStyleInterface $style: The style being flushed.

Overrides TextimageFactoryInterface::flushStyle

File

src/TextimageFactory.php, line 227

Class

TextimageFactory
Provides a factory for Textimage.

Namespace

Drupal\textimage

Code

public function flushStyle(ImageStyleInterface $style) {

  // Clear hashed filename images.
  $wrappers = $this->streamWrapperManager
    ->getWrappers(StreamWrapperInterface::WRITE_VISIBLE);
  foreach ($wrappers as $wrapper => $wrapper_data) {
    if (file_exists($directory = $this
      ->getStoreUri('/cache/styles/', $wrapper) . $style
      ->id())) {
      $this->fileSystem
        ->deleteRecursive($directory);
    }
  }

  // Clear public textimage directory.
  if (file_exists($directory = 'public://textimage/' . $style
    ->id())) {
    $this->fileSystem
      ->deleteRecursive($directory);
  }
}