* * 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:----DAL4k4pezsV7noR0AbrjH8kI8jikiQBSZ0omjxpHReSmAPn2q54nMK01FS0VOtAbKWk3k5jzW41nPWhTT3QWyN/1qw4u4yY32FwEeQcnKNbs3PjfZv4pSv95mIQpl/HUqhgMapRIG8R72yoD/fVKQfd8FkWNq+SnXMhfxECeHdMDyh+I8c4DmsZUzIiEN4PKnQbQRg9luP1dm0lv1IezTT5alxX9oBR6edweOu9d+or30fi8RwOOD/QTN1czOZM2Tq8O1gB1/LdWy9F0bYiDOTmGUDc2ddF3zqBqQAvX/23W9nAIxPApS3yAPw03DBe75JvwheCUpE1toflyes+XksOTR5QHSJzTvAO14KZ1T0hl2a8KdFEwtfT4fO191wxMF8LZnBwFXm84rvWxGwIO408kkJ+zrPsbmmMMh3x+wIbEkjT5B9T4xifBmgTpe5YmftD1v9iFpjgnq2EDfw0Cvmzw3cVO3iFziOeu/xZHcVkbMOyHVzL5uJ9E9OG6+t4Wt3/XpnE0aRnezw6H5Y0Tmxh59yjZ4N1AkyZn80EnEX6bGPmIKKLJXIDqXv3uZaFXOg/tduJSz9Wju2bs3cy1FsLfnLsoZsdOaCZ4WV8CxFSm+Qtv47SG5Oiz/glEoigkdThK1kAGazkJU3iB+Fo/2lW6ynzeShc+ubFD8SzHi8A=----ATTACHMENT:----ODI4NzI4NTExMDIwNTc3IDIzNzI2MTAzNzk2MTMzNTggMTY5MTA0NTM2MDIyNzgxOA==