|
@@ -3,12 +3,13 @@
|
|
|
namespace WorkflowBundle\EventListener;
|
|
|
|
|
|
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
|
|
|
+use Doctrine\Common\EventSubscriber;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Setea el container al workflow
|
|
|
*/
|
|
|
-class WorkflowEventListener
|
|
|
+class WorkflowEventListener implements EventSubscriber
|
|
|
{
|
|
|
|
|
|
private $container;
|
|
@@ -18,13 +19,29 @@ class WorkflowEventListener
|
|
|
$this->container = $container;
|
|
|
}
|
|
|
|
|
|
- public function postLoad(LifecycleEventArgs $args)
|
|
|
+ public function getSubscribedEvents()
|
|
|
{
|
|
|
- $object = $args->getObject();
|
|
|
+ return array(
|
|
|
+ 'prePersist',
|
|
|
+ 'postLoad',
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ function setContainer(LifecycleEventArgs $args){
|
|
|
+ $object = $args->getObject();
|
|
|
if ($object instanceof \WorkflowBundle\Entity\Workflow) {
|
|
|
$object->setContainer($this->container);
|
|
|
}
|
|
|
- return;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function postLoad(LifecycleEventArgs $args)
|
|
|
+ {
|
|
|
+ $this->setContainer($args);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function prePersist(LifecycleEventArgs $args)
|
|
|
+ {
|
|
|
+ $this->setContainer($args);
|
|
|
}
|
|
|
|
|
|
}
|