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 enter($subject, Transition $transition, Marking $marking)
 {
     if (null !== $this->dispatcher) {
         $event = new Event($subject, $marking, $transition);
         $this->dispatcher->dispatch('workflow.enter', $event);
         $this->dispatcher->dispatch(sprintf('workflow.%s.enter', $this->name), $event);
     }
     foreach ($transition->getTos() as $place) {
         $marking->mark($place);
         if (null !== $this->dispatcher) {
             $this->dispatcher->dispatch(sprintf('workflow.%s.enter.%s', $this->name, $place), $event);
         }
     }
 }