事件侦听器不适用于捆绑FMElfinder 参考代码:

问题描述

我正在尝试从包 FMelfinder 访问执行后事件。

遵循 events listeners / subscribers docs 后,事件侦听器不起作用。即使我在 cors_support 中将 true 选项设置为 fm_elfinder.yaml

我实际上没有收到错误消息。

我使用的是 Symfony 5.2 和 FMelfinder 捆绑包版本 10.1。

所以我想问是否有人知道我做错了什么或者我错过了什么,提前致谢。

参考代码

CallBackelfinder.PHP

<?PHP

namespace App\EventListener;

use FM\elfinderBundle\Event\elfinderPostExecutionEvent;

Class CallBackelfinder{

    /**
     * @param  elfinderPostExecutionEvent $event
     */
    public function onelfinderPost(elfinderPostExecutionEvent $event)
    {
        die('Post_Event');
       
        
        dd($event);
        if (!$event->hasErrors() && $event->getCommand() == 'upload') { // 'tmb','mkdir','open',etc...
            // do your stuff here
            // ...
            // you can perform a sub request
            $queryParameters = $event->getRequest()->query->all(); // getting original request parameters
            $queryParameters['cmd'] = 'info'; // changing the command to execute in sub request

            $jsonResponse = $event->subRequest(array(
                'instance' => $event->getInstance(),// you can also make a subrequest on an other instance
                'homeFolder' => $event->getHomeFolder() // and an other homeFolder
            ),$queryParameters);

            $data = json_decode($jsonResponse->getContent());
            dd($data);
            // work with sub request data
            // ...
        }
    }
}

fm_elfinder.yaml

fm_elfinder:
    assets_path: /assets
    instances:
        default:
            locale: fr
            cors_support: true
            editor: ckeditor
            theme: smoothness
            connector:
                roots:
                    uploads:
                        driver: LocalFileSystem
                        volume_id: 1
                        path: uploads
                        show_hidden: false
                        upload_allow: ['image/png','image/jpg','image/jpeg','video/mp4',video/ogg,'application/pdf']
                        upload_deny: ['all']
                        upload_max_size: 1M

services.yaml

    # Event suscriber to the elfinder Postevent listener
    elfinder_EventListener_PostExecution:
        class: App\EventListener\CallBackelfinder
        tags:
            - { name: fm_elfinder.event_listener,event: fm_elfinder.event.post_execution,method: onelfinderPost }

解决方法

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

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

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