/usr/share/php/Symfony/Component/Workflow/DependencyInjection/ValidateWorkflowsPass.php is in php-symfony-workflow 3.4.6+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | <?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Workflow\DependencyInjection;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\Workflow\Validator\StateMachineValidator;
use Symfony\Component\Workflow\Validator\WorkflowValidator;
/**
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class ValidateWorkflowsPass implements CompilerPassInterface
{
private $definitionTag;
public function __construct($definitionTag = 'workflow.definition')
{
$this->definitionTag = $definitionTag;
}
public function process(ContainerBuilder $container)
{
$taggedServices = $container->findTaggedServiceIds($this->definitionTag, true);
foreach ($taggedServices as $id => $tags) {
foreach ($tags as $tag) {
if (!array_key_exists('name', $tag)) {
throw new RuntimeException(sprintf('The "name" for the tag "%s" of service "%s" must be set.', $this->definitionTag, $id));
}
if (!array_key_exists('type', $tag)) {
throw new RuntimeException(sprintf('The "type" for the tag "%s" of service "%s" must be set.', $this->definitionTag, $id));
}
if (!array_key_exists('marking_store', $tag)) {
throw new RuntimeException(sprintf('The "marking_store" for the tag "%s" of service "%s" must be set.', $this->definitionTag, $id));
}
$this->createValidator($tag)->validate($container->get($id), $tag['name']);
}
}
}
private function createValidator($tag)
{
if ('state_machine' === $tag['type']) {
return new StateMachineValidator();
}
if ('single_state' === $tag['marking_store']) {
return new WorkflowValidator(true);
}
return new WorkflowValidator();
}
}
|