OneupUploaderBundle upload picture but doesn't call EventListener

╄→гoц情女王★ 提交于 2020-02-25 09:17:04

问题


I have this Bundle working on my Symfony2 app. Images are well uploaded, but the listener for persist the filename to the SQL table is not called on method onUpload.

Is strange, because all looks to be in order...

This is my services.yml

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

And this is my Listener:

 <?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();
    }
}

Could be great if somebody can give any suggestion! Thanks in advance!!


回答1:


Remove apostrophes around kernel.event_listener



来源:https://stackoverflow.com/questions/32296486/oneupuploaderbundle-upload-picture-but-doesnt-call-eventlistener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!