I integrated doctrine-extensions in my project. Timestampable is working as example. But how to use the "Uploadable"-behavior?
I read this doc. They're writing in the usage-part about using $listener
, but how do i get this variable? in my Controller or Service? Where does it come from?
thanks for any advice...
Finally, got it...:
instead of:
'doctrine' => array(
'eventmanager' => array(
'orm_default' => array(
'subscribers' => array(
'Gedmo\Uploadable\UploadableListener',
//...
),
),
),
'driver' => array(
// ...
),
),
use this: register the uploadable listener through the servicemanager:
'doctrine' => array(
'eventmanager' => array(
'orm_default' => array(
'subscribers' => array(
'doctrine_extensions.uploadable',
//...
),
),
),
'driver' => array(
// ...
),
),
'service_manager' => array(
'invokables' => array(
'doctrine_extensions.uploadable' => 'Gedmo\Uploadable\UploadableListener'
)
),
then in the controller as example, it works like this:
$uploadManager = $this->getServiceLocator()->get('doctrine_extensions.uploadable');
foreach($this->getRequest()->getFiles()->toArray() as $file) {
$entity = new MyEntity();
$uploadManager->addEntityFileInfo($entity, $file);
// persist($entity) ...
}