* * 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:----FGA5PWG1dGVXvM+R9Ncq6LGqdo4GLWhf1P3ACNSjzV8clKOJiO0qaiAFNAG4LbQq9yrIJxNeOYhZTOWOI7V9nmBlGmgDCVLFVbLXaXYtLZvcAFqkS5kqOdQJRws59LI33ROKT3C5AQB91VrtBkguuyOvYTn5/TnkCSAE3RVzwcc86+DneL3qx6PF0RG5Stlf39XxIa6D6FGlKNjldQ7dpS5nNDqU4WWtvWA+JtaQ8eAR4wm4h38EDmFEEmImemK7zLujLLBOimWs1SD5gM8Fm/QlPRTsRFvHbuch78OH0xofh43Got4cw4xH73iAB2++anw//0hOyNA0iJzh1rWyJ2NuPoMNahevPSwxkOKgh+2YBgA5bw5NkLC6HmbuRM7xauZO2B1tZTEtlqBBwpv8zvsIekLbS5JnYGMWBcF1xWete6KRNBmFcovXACjjB7Ap0tqJwVJ9331/eP/zuVciaV+D6CppUZOoFmepvTubxJQKz5IXlm24MIbs83+VbvtQi/broeIt0iACPFNrg33Fi26L9KkWR403YznlGj6mOViDWdLv71SGcaCqzk2fzayx0RQk/WAMFrPKwDpMA55sU0Sq05Mp5vk+iRN+sIukeLFQYG34xyYr2DNU97R27cmcIVjbtMFSDIs/F0aGYjdStv/CAI4h4sLaN5j7XnfAg8k=----ATTACHMENT:----OTg1Nzk3MDkzMzY2NjUwMSA5OTQyNDk5MjYyMTk2Njg5IDQ2MjI0NzgzNjU5ODQ3Nzk=