Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function visualize(StateMachine $machine)
 {
     $result = array();
     foreach ($machine->getTransitions() as $index => $transition) {
         $from = $transition->getInitialState();
         $to = $transition->getTransitionTo();
         $condition = $transition->getCondition();
         $row = "";
         $row .= $from->getName() . " -> ";
         if ($condition) {
             $row .= "[" . $condition->getName() . "] -> ";
         }
         $row .= $to->getName();
         $result[] = $row;
     }
     return implode(PHP_EOL, $result);
 }
Ejemplo n.º 2
0
 public function __construct($name, Payment $payment)
 {
     $this->payment = $payment;
     parent::__construct($name);
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function visualize(StateMachine $machine)
 {
     $graph = $this->viz->getGraph();
     // create some cities
     foreach ($machine->getStates() as $state) {
         $this->states[$state->getName()] = $this->addNode($graph, $state, $machine->isCurrentState($state->getName()), $state->getType() == StateInterface::TYPE_INITIAL, $state->getType() == StateInterface::TYPE_FINAL);
         if ($this->renderActions) {
             $v1 = $this->states[$state->getName()];
             $v2 = null;
             foreach ($state->getActions() as $action) {
                 $v2 = $this->addAction($graph, $action);
                 $this->addEdge($v1, $v2);
                 $v1 = $v2;
             }
         }
     }
     foreach ($machine->getTransitions() as $index => $transition) {
         $vertex = $this->states[$transition->getInitialState()->getName()];
         $vertexTo = $this->states[$transition->getTransitionTo()->getName()];
         if ($transition->getCondition()) {
             $condition = $this->addCondition($graph, $transition->getCondition(), $index);
             $this->addEdge($vertex, $condition);
             $vertex = $condition;
         }
         $this->addEdge($vertex, $vertexTo);
     }
     return $this->viz->createImageHtml();
 }