<?php
namespace Boab\CmsBundle\Filesystem;
use Boab\CmsBundle\Contract\FileUploaderInterface;
use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Psr\Log\LoggerInterface;
class PublicStorageFilesystem extends BaseFilesystem implements FileUploaderInterface
{
protected $cachManager;
public function __construct(FilesystemOperator $filesystemStorage, CacheManager $cacheManager, LoggerInterface $logger)
{
parent::__construct($filesystemStorage, $logger);
$this->cacheManager = $cacheManager;
}
public function resolveFilePath(string $path, string $extension):void
{
if(!in_array($extension, $this->allowedImageExtensions)){
return;
}
$this->cacheManager->resolve($path, 'thumbnail_small');
$this->cacheManager->resolve($path, 'thumbnail_medium');
}
public function delete(?string $file): void
{
parent::delete($file);
$this->cacheManager->remove($file);
}
}