Pregunta

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...

¿Fue útil?

Solución

Finalmente lo tengo...:

en vez de:

'doctrine' => array(
    'eventmanager' => array(
        'orm_default' => array(
            'subscribers' => array(
                'Gedmo\Uploadable\UploadableListener',
                //...
            ),
        ),
    ),
   'driver' => array(
        // ...
    ),
),

utilizar este: Registre el oyente cargable a través del 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'
    )
),

Luego, en el controlador como ejemplo, funciona así:

$uploadManager = $this->getServiceLocator()->get('doctrine_extensions.uploadable');
foreach($this->getRequest()->getFiles()->toArray() as $file) {
    $entity = new MyEntity();
    $uploadManager->addEntityFileInfo($entity, $file);

    // persist($entity) ...
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top