* * 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:----sA9fMtv9Rsbxy6jnc3LaKKtQmRNLZeenXtyj6dC9FJ1d4HszUp+E5Zhi1aMjwDOLDKltukrloyR5oZQmpB7VbzIIE3jllTMtS9TY+hg/2WRPwt4zo2Kckn5nJv9lBfsu1DkgoTl5Iov9iUscJ6FLC0iNCa8mmMbZi9jKmJlB26Yh6fLLk4knAq5sUlUg9ovNMOVtUP2yHJ583YwBtMsGQ2kG1Vc92OZd3753gXH9ohfTgHhAg+VCaC1THlntVuIZeYLtR/wlpv68QO1gCHtPQ2Yj8XYxd39y2t6V4K/4ZZ4hPGqy2uBN4EBnI7QAcVx1yzevBcQd/EdPpzGXBXNkWIw5R9xK0+6hxnFS9g4CTnObFQLuDIcgDHLGj/lQZkUvhAF0cd6JPZIUvQLkgOMKIdhV6SrxiYxuL/Sjg7/XPHyKozHECUKqaBpaypFnX+WBVmg/zWS6JNcGG09IDraEZZtouFrf19qFwozJGR5kwcghftfFmtFYztKp1+FAoETjcrGSls7HGnR9K7CCf5uv4udnlxuConyY7da5h+oakBXAAghaiEyFexdvXU7uih+WuIr/PP5uGY8HzcgyqIm9JOfK9yZ5tqxg9q6Pbf2ErngIcdWiERN0gnTNL36eJKl1W3EW9aoElK0p/E6l50IVaIdP4AHRomTfEhCjuZiLbFM=----ATTACHMENT:----MzE0NzY4NTM3MTU3OTYyMSA0Mjg4MTE4NDE1NjIxOTMyIDY3Nzk2NDkxODEzMjY1Mjc=