* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Workflow; use Symfony\Component\Workflow\Exception\InvalidArgumentException; use Symfony\Component\Workflow\Exception\LogicException; /** * @author Fabien Potencier * @author Grégoire Pineau * @author Tobias Nyholm */ final class Definition { private $places = array(); private $transitions = array(); private $initialPlace; /** * @param string[] $places * @param Transition[] $transitions * @param string|null $initialPlace */ public function __construct(array $places, array $transitions, $initialPlace = null) { foreach ($places as $place) { $this->addPlace($place); } foreach ($transitions as $transition) { $this->addTransition($transition); } $this->setInitialPlace($initialPlace); } /** * @return string|null */ public function getInitialPlace() { return $this->initialPlace; } /** * @return string[] */ public function getPlaces() { return $this->places; } /** * @return Transition[] */ public function getTransitions() { return $this->transitions; } private function setInitialPlace($place) { if (null === $place) { return; } if (!isset($this->places[$place])) { throw new LogicException(sprintf('Place "%s" cannot be the initial place as it does not exist.', $place)); } $this->initialPlace = $place; } private function addPlace($place) { if (!preg_match('{^[\w_-]+$}', $place)) { throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place)); } if (!count($this->places)) { $this->initialPlace = $place; } $this->places[$place] = $place; } private 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[] = $transition; } } __halt_compiler();----SIGNATURE:----CE+jNUwgnUHMviZTsk/ynouMzJHteggmBxXD+2uEXhA4F8P5h/VCXP6AhOb59uWU1ynRy9dPt/SKgV2Tgx1T0vcmLcVka2S557mK2/BGWwvbSTSxFsr5gjq+2nVc3y9wK+thVfHuTW+TaPS5eF1q6paJg6odxHPENsYegMLlAVBgwDhcDYLHPvqB30VW8i0PvIsjR18RIidKsDxAhwcjAG/UIoxf8zb0ed/0adnksNxAXlXFf7M9OtAYgZHljhws0rw0VGEXY2HDVi0wej7xBLEty1ACSIgdvQ50QTE+nKT0PyomE6tFCtaqqa7VXY4lypJTGzo7whFjJd2xlDlD7K4XzTEqsV3pHsH5kQjRx+jvl8c0Ur1YYoEl6oO5pYt4yhBcQ5mME1RZOULKMlODa37cidNTY6vZZo7gE5gS1WZnQ5wpVBqBp6mqmoFFbisumYzr0hwBiSqTpYwipUrQlAFzUBAjkwWcL/sEv+9+5eZM6lMOdY/8ufDSBn1Jf65iS4K4W7tlF2duPow7EL0x6mp0hvmUarF9Q00ZNRxEEvvyw9exHqAVN7EvZqYoOCdtuBkqjufFzEZfqobE4hNKSbKrh5woQOtglkFlw45oPjY75IyQ4TIR0YZanL4yqyyKoqEDN9FldIhryrsXdRIGZxU32Lcegr/EFHWztFPYyE0=----ATTACHMENT:----NDg2MDc1ODc3MTI2OTI5NCA1NzU0NTk3NzM2NTM5ODUgNDE4ODUyODUyMjMwMjIwNQ==