在通过Symfony应用程序中的FM Elfinder大声上传文件后,我想执行一些特定的操作。我的事件订阅者可以使用PRE_EXECUTION事件,但是POST_EXECUTION事件只是不执行任何操作,并且似乎被完全忽略了。
我是否错过配置中的某些内容?有人有同样的问题吗?
我遵循了这些instructions,但没有任何效果。如我所说,PRE_EXECUTION可以正常工作,但POST_EXECUTION事件将被忽略。
感谢任何想法
事件订阅者类别
<?php declare(strict_types=1);
namespace App\EventSubscriber;
use FM\ElfinderBundle\Event\ElFinderEvents;
use FM\ElfinderBundle\Event\ElFinderPostExecutionEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ElFinderSubscriber implements EventSubscriberInterface
{
public function __construct()
{
}
public static function getSubscribedEvents()
{
return [
ElFinderEvents::POST_EXECUTION => 'postUpload',
];
}
public function postUpload(ElFinderPostExecutionEvent $event)
{
// Do something
}
}
Elfinder配置
fm_elfinder:
instances:
default: &default
include_assets: true
relative_path: true
editor: custom
editor_template: '@App/easy_admin/elfinder-page.html.twig'
locale: '%locale%'
cors_support: true
connector:
roots:
uploads:
driver: LocalFileSystem
path: upload
upload_allow: .....
upload_deny: ['all']
upload_max_size: 12M
Elfinder模板
{% extends ['easy_admin/layout.html.twig', '@App/easy_admin/layout.html.twig', '@EasyAdmin/default/layout.html.twig'] %}
{% block head_stylesheets %}
{{ parent() }}
{{ include("@FMElfinder/Elfinder/helper/assets_css.html.twig") }}
{% endblock %}
{% block head_javascript %}
{{ parent() }}
<script src="{{ asset("#{prefix}/jquery-ui/jquery-ui.min.js") }}"></script>
<script src="{{ asset("#{prefix}/elfinder/dist/js/elfinder.min.js") }}"></script>
<script src="{{ asset("#{prefix}/elfinder/dist/js/i18n/elfinder.#{locale|split('_')[0]}.js") }}"></script>
<script type="text/javascript" charset="utf-8">
// Documentation for client options:
// https://github.com/Studio-42/elFinder/wiki/Client-configuration-options
$(document).ready(function() {
$('#elfinder').elfinder(
{
cssAutoLoad : false, // Disable CSS auto loading
baseUrl : './', // Base URL to css/*, js/*
url : '{{ path('ef_connect')|e('js') }}',
lang: '{{ app.request.getLocale() }}'
},
function(fm, extraObj) {
var title = document.title;
fm.bind('open', function() {
var path = '',
cwd = fm.cwd();
if (cwd) {
path = fm.path(cwd.hash) || null;
}
document.title = path ? title + ':' + path : title;
}).bind('destroy', function() {
document.title = title;
});
}
);
});
</script>
{% endblock %}
{% block content_title %}
{% trans %}easy_admin.filemanager{% endtrans %}
{% endblock %}
{% block main %}
<div id="elfinder"></div>
{% endblock %}
{% block _hidden %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>elFinder 2.1.x source version with PHP connector</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2" />
{% endblock %}