* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Workflow\Validator; use Symfony\Component\Workflow\Definition; use Symfony\Component\Workflow\Exception\InvalidDefinitionException; /** * @author Tobias Nyholm */ class StateMachineValidator implements DefinitionValidatorInterface { public function validate(Definition $definition, $name) { $transitionFromNames = array(); foreach ($definition->getTransitions() as $transition) { // Make sure that each transition has exactly one TO if (1 !== count($transition->getTos())) { throw new InvalidDefinitionException(sprintf('A transition in StateMachine can only have one output. But the transition "%s" in StateMachine "%s" has %d outputs.', $transition->getName(), $name, count($transition->getTos()))); } // Make sure that each transition has exactly one FROM $froms = $transition->getFroms(); if (1 !== count($froms)) { throw new InvalidDefinitionException(sprintf('A transition in StateMachine can only have one input. But the transition "%s" in StateMachine "%s" has %d inputs.', $transition->getName(), $name, count($froms))); } // Enforcing uniqueness of the names of transitions starting at each node $from = reset($froms); if (isset($transitionFromNames[$from][$transition->getName()])) { throw new InvalidDefinitionException(sprintf('A transition from a place/state must have an unique name. Multiple transitions named "%s" from place/state "%s" where found on StateMachine "%s". ', $transition->getName(), $from, $name)); } $transitionFromNames[$from][$transition->getName()] = true; } } } __halt_compiler();----SIGNATURE:----YtoACKfaP5WSEBQlfWPl7PU6l2N0X2KAF7qYsUWFm5+Q0TzEQn23OU5pRKo01sbIuWz5sZwFcqyIEV1EF+XII7I1WV1gaAyv23A1C57vd1x28wVyBLkqBr6YzIttxFZc+pRnGYeTM6m+dOaNQKbxpZHnXsfma5TC6H55rLky9Ao7w85jfURfslXvcDe7rTe2Ra6hYU/tqyyh29j0Nj4Olxm4rtjsZF+FU2hb3wpaj33klDY1dT/+PUrZLn6ADh5Lo8jwuLqLE3D7YsLd99OzT3In2yZN/KF4zh0cpAsU5C9SHIijZuUgPit35RaJtsy39z1Qp5YVTDz/UucOHbBnYqp57S3bXa5yIJ4/sl5Chc8Ltzy9HLLAciqPxpcO2FnA4tHNt6k4J9kbVZpSK9M1+ErHzxPGmIAfdP2a9CVGs9LFIl8SX2w06LEWCk65kEdvG5pTl1DGHZFFX5tCqSvRd5/iW1MfbETpSpd5oEEFfBGmcGVaCUVYrakNWnSI8Szu1sgXHtTJoVxinYbqK1mpcOFhM+7IOunzXE5oKF6WCOwMzd9g2n0oY4L7uIVrNUNcJHqVi01etzAvJQHtVu38nT2HLGufjKgBz67p5W8Ut6cJ+kyQC5kLNJ5Xfu+hoLkjSVy5tBOODyEKVE7D3/fk0w3KNgH1mpp7rBvEUt/JeX0=----ATTACHMENT:----NjM4MjcwNDgyNTk3NDc4NyAyODA0OTUzNTc4ODUzNTYzIDM3NTcxNzA5OTc0OTgyNTg=