Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/244.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Liip Imagine在Symfony 5中的侦听器事件上生成错误的删除路径_Php_Symfony_Symfony5_Liipimaginebundle - Fatal编程技术网

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

Php Liip Imagine在Symfony 5中的侦听器事件上生成错误的删除路径,php,symfony,symfony5,liipimaginebundle,Php,Symfony,Symfony5,Liipimaginebundle,我用的是Symfony 5。我已经配置好了,图像已经生成并正确显示 但是,我在要删除图像的postUpdate和preRemove的事件侦听器上遇到问题 监听器本身工作正常,但Liip Imagine为存储生成了错误的路径,因此我被数百个从未被正确删除的图像所困扰 我的配置相当标准: parameters: img_path: "/public/assets/img/uploaded" display_img_path: "/assets/img/uploa

我用的是Symfony 5。我已经配置好了,图像已经生成并正确显示

但是,我在要删除图像的
postUpdate
preRemove
的事件侦听器上遇到问题

监听器本身工作正常,但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 ], mode: outbound, allow_upscale: true }
    add_single_thumbnail:
      quality: 60
      filters:
        thumbnail: { size: [ 300 ], mode: outbound, allow_upscale: true }
    add_single_thumbnail_carousel:
      quality: 80
      filters:
        thumbnail: { size: [ 800 ], mode: outbound, 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\u profile\u public\u缩略图/6012E6DBF4CAD3416FB609E343470C27778F491DDEBC238FA2D9B3676FAE007CC439BCB912FAA006DB1BC23A6D17759E.jpeg

第一部分是正确的(
C:\Bitnami\wampstack-7.4.9-0\apps\coleg/public/media/cache/user\u profile\u public\u缩略图/
),但其余部分不是

文件夹结构是这样的

基本上它没有“后缀”,我想你会叫它。意思是
资产/img/上传的
,这是我存储原始图像的地方


我很确定我在某个地方有什么配置错误的地方,但我无法确定


通过查看您的代码,您只是从缓存中删除了文件,而不是在其绝对路径上取消实际文件的链接
$this->cacheManager->remove($entity->getPath(),'user\u profile\u public\u缩略图')
是从绝对路径中删除文件,但路径是错误的。