execute($args, DoctrineEvents::PRE_PERSIST); } /** * @param LifecycleEventArgs $args */ public function postPersist(LifecycleEventArgs $args) { $this->execute($args, DoctrineEvents::POST_PERSIST); } /** * @param LifecycleEventArgs $args */ public function preUpdate(LifecycleEventArgs $args) { $this->execute($args, DoctrineEvents::PRE_UPDATE); } /** * @param LifecycleEventArgs $args */ public function postUpdate(LifecycleEventArgs $args) { $this->execute($args, DoctrineEvents::POST_UPDATE); } /** * @param LifecycleEventArgs $args */ public function preRemove(LifecycleEventArgs $args) { $this->execute($args, DoctrineEvents::PRE_REMOVE); } /** * @param LifecycleEventArgs $args */ public function postRemove(LifecycleEventArgs $args) { $this->execute($args, DoctrineEvents::POST_REMOVE); } /** * @param LifecycleEventArgs $args * @param string $eventName */ public function execute(LifecycleEventArgs $args, $eventName = DoctrineEvents::PRE_PERSIST) { $entity = $args->getEntity(); $entityManager = $args->getEntityManager(); $entityClass = get_class($entity); // la $entity esta dentro de las entidades con workflow if (in_array($entityClass, WorkFlowEntityClasses::getConstants())) { $doctrine2WorkFlowActionRepository = $entityManager->getRepository('WorkflowBundle:Doctrine2WorkFlowAction'); $doctrine2WorkFlowActions = $doctrine2WorkFlowActionRepository->findAllByEventAndEntityClass($eventName, $entityClass); foreach ($doctrine2WorkFlowActions as $doctrine2WorkFlowAction) { $actions = $doctrine2WorkFlowAction->getActions(); foreach ($actions as $action) { // $action->execute($entity); // ejecutar accion, template, etc } } } } }