Ejemplo n.º 1
0
 public function testConstructor()
 {
     $transition = new Transition('name', 'a', 'b');
     $this->assertSame('name', $transition->getName());
     $this->assertSame(array('a'), $transition->getFroms());
     $this->assertSame(array('b'), $transition->getTos());
 }
Ejemplo n.º 2
0
 public function addTransition(Transition $transition)
 {
     $name = $transition->getName();
     foreach ($transition->getFroms() as $from) {
         if (!isset($this->places[$from])) {
             throw new LogicException(sprintf('Place "%s" referenced in transition "%s" does not exist.', $from, $name));
         }
     }
     foreach ($transition->getTos() as $to) {
         if (!isset($this->places[$to])) {
             throw new LogicException(sprintf('Place "%s" referenced in transition "%s" does not exist.', $to, $name));
         }
     }
     $this->transitions[$name] = $transition;
 }
Ejemplo n.º 3
0
 private function transition($subject, Transition $transition, Marking $marking)
 {
     if (null === $this->dispatcher) {
         return;
     }
     $event = new Event($subject, $marking, $transition);
     $this->dispatcher->dispatch('workflow.transition', $event);
     $this->dispatcher->dispatch(sprintf('workflow.%s.transition', $this->name), $event);
     $this->dispatcher->dispatch(sprintf('workflow.%s.transition.%s', $this->name, $transition->getName()), $event);
 }