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()); }
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; }
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); } } }