OneupUploaderBundle上传图片但不调用EventListener

时间:2015-08-30 12:17:42

标签: php symfony oneupuploaderbundle

我有这个Bundle正在使用我的Symfony2应用程序。图像上传得很好,但是在onUpload方法上没有调用将文件名保存到SQL表的监听器。

很奇怪,因为所有人看起来都井井有条......

这是我的services.yml

services:
luisma.upload_listener:
    class: "LuismaBundle\Services\UploadListener"
    arguments: [@doctrine]
    tags:
        - { name: 'kernel.event_listener', event: oneup_uploader.post_persist, method: onUpload }

这是我的听众:

 <?php

namespace LuismaBundle\Services;

use Oneup\UploaderBundle\Event\PostPersistEvent;
use LuismaBundle\Entity\MotorsAdsFile;

class UploadListener
{
    protected $manager;

    public function __construct(EntityManager $manager)
    {
        $this->manager = $manager;
    }

    public function onUpload(PostPersistEvent $event)
    {
        $file = $event->getFile();

        $object = new MotorsAdsFile();
        $object->setFilename($file->getPathName());
        $this->manager->persist($object);
        $this->manager->flush();
    }
}

如果有人可以提出任何建议,那可能会很棒!在此先感谢!!

1 个答案:

答案 0 :(得分:0)

删除kernel.event_listener

周围的撇号