I have many ORM entities which I want to link them to their corresponding files. Example: the entity Motors with MotorsFile, Houses with HousesFile, ...
These ORM entities can be easily definied. This is not a problem. But, my problem is: "Is it possible to define many ORM entities such us MotorsFile and HousesFile while using OneupUploaderBundle?"
I asked this question because processing these uploaded file with doctrine needs creating an event listener to PostUploadEvent
and PostPersistEvent
. The event listener would be something like that:
<?php
namespace Acme\HelloBundle\EventListener;
use Oneup\UploaderBundle\Event\PostPersistEvent;
use Minn\AdsBundle\Entity\MotorsAdsFile;
class UploadListener
{
protected $manager;
public function __construct(EntityManager $manager)
{
$this->manager = $manager;
}
public function onUpload(PostPersistEvent $event)
{
$file = $event->getFile();
$object = new MotorsFile();
$object->setFilename($file->getPathName());
$this->manager->persist($object);
$this->manager->flush();
}
}
But, this code will allow me only to persist one entity (for this example MotorsFile). So, is it possible to specify the uploaded file is corresponding to which entity?
Thanks...