* * 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 WorkflowValidator implements DefinitionValidatorInterface { private $singlePlace; /** * @param bool $singlePlace */ public function __construct($singlePlace = false) { $this->singlePlace = $singlePlace; } public function validate(Definition $definition, $name) { // Make sure all transitions for one place has unique name. $places = array_fill_keys($definition->getPlaces(), array()); foreach ($definition->getTransitions() as $transition) { foreach ($transition->getFroms() as $from) { if (in_array($transition->getName(), $places[$from])) { throw new InvalidDefinitionException(sprintf('All transitions for a place must have an unique name. Multiple transitions named "%s" where found for place "%s" in workflow "%s".', $transition->getName(), $from, $name)); } $places[$from][] = $transition->getName(); } } if (!$this->singlePlace) { return; } foreach ($definition->getTransitions() as $transition) { if (1 < count($transition->getTos())) { throw new InvalidDefinitionException(sprintf('The marking store of workflow "%s" can not store many places. But the transition "%s" has too many output (%d). Only one is accepted.', $name, $transition->getName(), count($transition->getTos()))); } } } } __halt_compiler();----SIGNATURE:----DiFDti+f1zNO5V4k5mAW0DRMSoJc3RkYcABzKnJU1KJG+ozUmQIS6xrQq01J4WuWHDxojSk2TUaSEQfYUyfFzR5sXm2Q7h885oApv1xS5OC6BnhgcyYgjjz7KxPPjXbdt3yWRzYXN1x/0fGjX7d2epU620kryfET+ZMf8d7ehF10YL2tfVFgI0IUAv4S/qBPsgRgysk3eExZvoEYSGp5fcvgo/T1LMpsCzkJ1u9G67/Oxq5rDXLlE5R6nEJyOXRBLGBuHM1Foo2vdQOfBdzHCjdpgWl5ybJVMgZ4yyVv35FBSEqPe58llAwtZL4boPIYMyHCULlscHHjS/PsbAt9ay9jGCdu42VtBQLlKv2Vml70asY9Vzq4BAZ/nx3MSq2CZHO2q2BBXL9oSY7JtdwbLq475aJbzFZO8p4DRz3dlTXGIY++iDDsNrrijgU8bDLzdyHRPpB655kzRUs8eUyp0OPXXYOLfY5QFBH0B7mIWxnu1VwVSF2+EeSpm02DNFJ4JWFxTH/ANvROOAJF/FmkKTC+RkFKkbS4hLW8jAkYLS4FOhQ3TLSx1z5NHakA4aak1UoSkgE2vxISPBbnN/i0zJVm3wsIZ70IfpMDPKncY2TirTpCxshZgNiKxQyu9L0/ol1C8a/k8Gw5iSPE+CMj7/vgZeLquxyUVmknmxAfSbE=----ATTACHMENT:----NzMyNDE0NjIwMTQ2NTE5MyA2MzM1OTk4NzE1MzkwMzgxIDIxNzI0NzAyOTc0MDM=