public function TextimageFactory::flushAll in Textimage 8.4
Same name and namespace in other branches
- 8.3 src/TextimageFactory.php \Drupal\textimage\TextimageFactory::flushAll()
Cleans up Textimage.
This will remove all image files generated via Textimage, flush all the image styles, clear all cache and all store entries on the db.
Overrides TextimageFactoryInterface::flushAll
File
- src/
TextimageFactory.php, line 244
Class
- TextimageFactory
- Provides a factory for Textimage.
Namespace
Drupal\textimageCode
public function flushAll() {
// Flush Textimage relevant styles so to invalidate the image styles cache
// tags.
$styles = ImageStyle::loadMultiple();
foreach ($styles as $style) {
$style
->flush();
}
// Clear whatever directory structure remains, checking in all available
// schemes.
$wrappers = $this->streamWrapperManager
->getWrappers(StreamWrapperInterface::WRITE_VISIBLE);
foreach ($wrappers as $wrapper => $wrapper_data) {
if (file_exists($directory = $this
->getStoreUri(NULL, $wrapper))) {
$this->fileSystem
->deleteRecursive($directory);
}
}
// Remove the URL generation directory.
if (file_exists($directory = 'public://textimage')) {
$this->fileSystem
->deleteRecursive($directory);
}
// Wipe Textimage cache.
$this->cache
->deleteAll();
$this->logger
->notice('All Textimage images were removed.');
}