Удаление эскизов с носителя / кеша в пакете liip think

У меня есть пакет, установленный и настроенный с помощью Sonata Admin Bundle, когда я пытаюсь удалить изображение, изображение удаляется из папки правильно, но не эскиз, хранящийся в носителе / ​​кеше.

это мой liip_imagine yml:

liip_imagine:

loaders:
    loader_s3_thumbnail:
        stream:
            wrapper: gaufrette://questions_image_fs/

filter_sets:
    question_thumb:
        cache: default
        data_loader: loader_s3_thumbnail
        # list of transformations to apply (the "filters")
        filters:
            thumbnail: { size: [120, 120], mode: outbound }

    provider_thumb:
        cache: default
        data_loader: loader_s3_thumbnail
        # list of transformations to apply (the "filters")
        filters:
            thumbnail: { size: [200, 200], mode: inset }

Любая идея, почему или как удалить эти миниатюры?


person Krleza    schedule 23.11.2017    source источник


Ответы (1)


Workmate удалось решить эту проблему с помощью Liip cachemanager. Вот код:

Услуга:

  question.admin_bundle.event_listener.delete_thumbnails:
    class: QuestionAdminBundle\EventListener\DeleteThumbnails
    arguments: [ "@liip_imagine.cache.manager" ]
    tags:
        - { name: kernel.event_listener, event: vich_uploader.pre_remove, method: postRemove}  

Php:

use Liip\ImagineBundle\Imagine\Cache\CacheManager;
[...]
public function __construct(CacheManager $cacheManager)
{
     Add a comment to this line
     $this->cacheManager = $cacheManager;
}
[...]
public function postRemove(Event $event)
{
    $image = $event->getObject();
    if ($image instanceof Image){
        $this->cacheManager->remove($image->getName());
    }
 }
person Krleza    schedule 30.11.2017