问题
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