|
@@ -2,11 +2,11 @@
|
|
|
|
|
|
namespace WorkflowBundle\Event;
|
|
|
|
|
|
+use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
|
use Symfony\Component\Workflow\Event\Event;
|
|
|
use Symfony\Component\Workflow\Event\GuardEvent;
|
|
|
use WorkflowBundle\Services\ProducerService;
|
|
|
-use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
|
|
|
# Ayuda:
|
|
|
# http://blog.eleven-labs.com/en/symfony-workflow-component/
|
|
@@ -16,12 +16,12 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
|
|
|
|
class EventSubscriber implements EventSubscriberInterface
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @var ContainerInterface
|
|
|
*/
|
|
|
private $container;
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @var ProducerService
|
|
|
*/
|
|
@@ -80,7 +80,7 @@ class EventSubscriber implements EventSubscriberInterface
|
|
|
$this->completeAction($action, $params);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param Event $event
|
|
|
*/
|
|
@@ -96,20 +96,20 @@ class EventSubscriber implements EventSubscriberInterface
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* @param Event $event
|
|
|
*/
|
|
|
public function guard(GuardEvent $event)
|
|
|
{
|
|
|
- //$event->setBlocked(true);
|
|
|
+ //$event->setBlocked(true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @param Event $event
|
|
|
* @param string $eventName
|
|
|
* @param string $eventReference
|
|
|
- *
|
|
|
+ *
|
|
|
* @return array
|
|
|
*/
|
|
|
public function getActions($event, $eventName, $eventReference)
|
|
@@ -118,13 +118,17 @@ class EventSubscriber implements EventSubscriberInterface
|
|
|
|
|
|
$em = $this->container->get("doctrine.orm.entity_manager");
|
|
|
$object = $event->getSubject();
|
|
|
- $objectClass = (string) get_class($object);
|
|
|
+ $objectClass = (string)get_class($object);
|
|
|
+ if ($objectClass == 'FTTHBundle\\Entity\\ONU') {
|
|
|
+ $object->getLogOLT()->setPending();
|
|
|
+ $em->flush();
|
|
|
+ }
|
|
|
$logger->info("EVENT {$eventName}:{$eventReference} => {$objectClass }_id_{$object->getId()}");
|
|
|
-
|
|
|
+
|
|
|
$workflowName = $object->getWorkflowName();
|
|
|
$actions = $em->getRepository("WorkflowBundle:Action")
|
|
|
- ->findByWorkflowAndEventRef($workflowName, $eventReference);
|
|
|
-
|
|
|
+ ->findByWorkflowAndEventRef($workflowName, $eventReference);
|
|
|
+
|
|
|
$new_actions = array();
|
|
|
foreach ($actions as $action) {
|
|
|
if (in_array($eventName, $action->getEvent()) AND is_a($object, $action->getObjectClass())) {
|
|
@@ -132,7 +136,7 @@ class EventSubscriber implements EventSubscriberInterface
|
|
|
}
|
|
|
}
|
|
|
$actions = $new_actions;
|
|
|
- $logger->info("EVENT Found ". count($actions) . " actions to apply", compact('workflowName', 'eventReference'));
|
|
|
+ $logger->info("EVENT Found " . count($actions) . " actions to apply", compact('workflowName', 'eventReference'));
|
|
|
|
|
|
return $actions;
|
|
|
}
|
|
@@ -147,7 +151,7 @@ class EventSubscriber implements EventSubscriberInterface
|
|
|
$object = $params['entity'];
|
|
|
$routing_key = "";
|
|
|
if (getenv("AMQP_KEY") !== false) {
|
|
|
- $routing_key = getenv("AMQP_KEY");
|
|
|
+ $routing_key = getenv("AMQP_KEY");
|
|
|
}
|
|
|
|
|
|
$this->producerService->publishMessage($action, $object, $routing_key);
|