ActionEventSubscriber.php 858 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace WorkflowBundle\EventListener;
  3. use Doctrine\Common\EventSubscriber;
  4. use Doctrine\ORM\Event\LifecycleEventArgs;
  5. use WorkflowBundle\Entity\Action;
  6. use WorkflowBundle\Utils\DoctrineEvents;
  7. class ActionEventSubscriber implements EventSubscriber
  8. {
  9. /**
  10. * @var array
  11. */
  12. protected $twigParams;
  13. public function __construct()
  14. {
  15. $this->twigParams = func_get_args();
  16. }
  17. /**
  18. * @return array
  19. */
  20. public function getSubscribedEvents()
  21. {
  22. return array(
  23. DoctrineEvents::POST_LOAD,
  24. );
  25. }
  26. /**
  27. * @param LifecycleEventArgs $args
  28. */
  29. public function postLoad(LifecycleEventArgs $args)
  30. {
  31. $entity = $args->getEntity();
  32. if ($entity instanceof Action) {
  33. $entity->setTwigParams($this->twigParams);
  34. }
  35. }
  36. }