Liip Imagine在Symfony 5中的侦听器事件上生成错误的删除路径

问题描述

我正在将Liip Imagine Bundle用于Symfony5。我已经对其进行了配置,图像已生成并正确显示

但是,我要删除图像的postUpdatepreRemove的事件侦听器出现问题。

侦听器本身可以正常工作,但是Liip Imagine为存储生成错误的路径,因此,我陷入了成百上千个永远不会被正确删除的图像。

我的配置相当标准:

parameters:
  img_path: "/public/assets/img/uploaded"
  display_img_path: "/assets/img/uploaded/"
  google_secret_key: '%env(GOOGLE_KEY)%'
  site_name: '%env(SITE_NAME)%'
  liip_img_cache_path: '/media/cache'
liip_imagine:
  resolvers:
    default:
      web_path:
        web_root: "%kernel.project_dir%/public"
        cache_prefix: "%liip_img_cache_path%"
  filter_sets:
    cache: ~
    listing_show_thumbnails:
      quality: 60
      filters:
        thumbnail: { size: [ 450 ],mode: outbound,allow_upscale: true }
    user_profile_public_thumbnail:
      quality: 60
      filters:
        thumbnail: { size: [ 600 ],allow_upscale: true }
    add_single_thumbnail:
      quality: 60
      filters:
        thumbnail: { size: [ 300 ],allow_upscale: true }
    add_single_thumbnail_carousel:
      quality: 80
      filters:
        thumbnail: { size: [ 800 ],allow_upscale: true }

而且设置监听器的方式也是标准的。

class CacheImageListener
{
    protected $cacheManager;
    protected $parameterBag;

    public function __construct(CacheManager $cacheManager,ParameterBagInterface $parameterBag)
    {
        $this->cacheManager = $cacheManager;
        $this->parameterBag = $parameterBag;
    }

    public function postUpdate(LifecycleEventArgs $args)
    {
        //... some other stuff here
    }

    public function preRemove(LifecycleEventArgs $args)
    {
        $entity = $args->getEntity();
        if ($entity instanceof UserImage) {
            if($this->cacheManager->isstored($entity->getPath(),'user_profile_public_thumbnail')) {
                $this->cacheManager->remove($entity->getPath(),'user_profile_public_thumbnail');
            }
        }
        // other functions bellow

功能生成的路径

$this->cacheManager->isstored...

C:\Bitnami\wampstack-7.4.9-0\apps\coleg/public/media/cache/user_profile_public_thumbnail/6012e6dbf4cad3416fb609e343470c27778f491dd1debc238fa2d9b3676fae007cc439bcb912feaca006db1bc23a6d17759e.jpeg

第一部分是正确的(C:\Bitnami\wampstack-7.4.9-0\apps\coleg/public/media/cache/user_profile_public_thumbnail/),其余部分是错误的。

文件夹结构就像这样

基本上,它缺少“后缀”,我想您会称呼它。意思是assets/img/uploaded,这是我存储原始图像的地方。


我很确定我在某处配置不正确,但是我无法将手指放在上面。

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)