* * 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:----Xb6syjLmVTEKD0NLEp5tQ+Ttf/BpaCMV90+tVGJ0RmvOzovJFT/CF4/Vi3V+mSuFH9g+sBAdZ7KfImESUneEAT3VJnof31E1er38bpI1D9W3r/w0UC53Q1HKJ5jhnC+qeel3zmWRvMixqQfv9hQeoJHLJDSrJDe87xRrIXyS6dq/BT6woJAk4hVq5djahAyb7S6PuKD2g4RfFJNnHhAZhUqitK8Ed56v6YLUA+V2xYGoZGou5OF+kQtgd3bnjoNN3KkRGYYQUJXe7APCol3hFZr6t4INXtdE4Tb0CHeITDoIaQSREdXy+wCZFKk1ftfsSQ+O85oapvnsA/73AqTQqlEqC1Du16IMUamyAujqX7pc83i5ssfW03LbIrfvjntt3aFnYatUn91xeA3j9H2AxSejvumer9ZpZTFa9qWJjCXUoqvYM02q/Z560G3WahJdctS59UQ9xxpp5B+y3+dDQGlxbhwyPjGo3FgDXmzWASOhjO9yPjhYJIMKpOmyD0HAnA9Shx7mhh8cJ3Wm7ggCnTTA7j3Spu4G74a08xAQsKlfu0R1JWd7Gfq+pS5onnavdv0CFb00KAQuAYnG8VMzAz0zHPUNM8kFSWhU3gTOAiuzgBK0ruAXfO8bmOXvZeQVILLXF3nust9cEOeUSnphDu8medVhHSUKxp9tNDV1jdY=----ATTACHMENT:----NjEwNTg4ODEwOTg5MzM1OSA4MzYwNjU4NTEwNDQzNTc0IDY3NzAwODQ0NjQ0MjY1NDc=