<?php
namespace App\Admin\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
use Artgris\Bundle\FileManagerBundle\Event\FileManagerEvents;
class FileManagerSubscriber implements EventSubscriberInterface
{
protected $cacheManager;
public function __construct(CacheManager $cacheManager)
{
$this->cacheManager = $cacheManager;
}
public static function getSubscribedEvents(): array
{
// return the subscribed events, their methods and priorities
return [
FileManagerEvents::POST_UPDATE => [
['postUpdate', 0]
],
];
}
public function postUpdate(\Symfony\Component\EventDispatcher\GenericEvent $event)
{
$response=$event->getArgument("response");
foreach ($response["files"] as $file) {
if(isset($file->url)){
$this->cacheManager->remove(urldecode($file->url));
}
}
}
}
?>