Skip to content

Commit 8e805ee

Browse files
ro0NLlyrixx
authored andcommitted
[Workflow] Clarify validator API + fixed unknown "scalar" marking store
1 parent fed2ea7 commit 8e805ee

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

DependencyInjection/Compiler/ValidateWorkflowsPass.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1717
use Symfony\Component\Workflow\Validator\DefinitionValidatorInterface;
18-
use Symfony\Component\Workflow\Validator\SinglePlaceWorkflowValidator;
1918
use Symfony\Component\Workflow\Validator\StateMachineValidator;
2019
use Symfony\Component\Workflow\Validator\WorkflowValidator;
2120

@@ -24,11 +23,6 @@
2423
*/
2524
class ValidateWorkflowsPass implements CompilerPassInterface
2625
{
27-
/**
28-
* @var DefinitionValidatorInterface[]
29-
*/
30-
private $validators = array();
31-
3226
public function process(ContainerBuilder $container)
3327
{
3428
$taggedServices = $container->findTaggedServiceIds('workflow.definition');
@@ -45,7 +39,7 @@ public function process(ContainerBuilder $container)
4539
throw new RuntimeException(sprintf('The "marking_store" for the tag "workflow.definition" of service "%s" must be set.', $id));
4640
}
4741

48-
$this->getValidator($tag)->validate($definition, $tag['name']);
42+
$this->createValidator($tag)->validate($definition, $tag['name']);
4943
}
5044
}
5145
}
@@ -55,23 +49,16 @@ public function process(ContainerBuilder $container)
5549
*
5650
* @return DefinitionValidatorInterface
5751
*/
58-
private function getValidator($tag)
52+
private function createValidator($tag)
5953
{
60-
if ($tag['type'] === 'state_machine') {
61-
$name = 'state_machine';
62-
$class = StateMachineValidator::class;
63-
} elseif ($tag['marking_store'] === 'scalar') {
64-
$name = 'single_place';
65-
$class = SinglePlaceWorkflowValidator::class;
66-
} else {
67-
$name = 'workflow';
68-
$class = WorkflowValidator::class;
54+
if ('state_machine' === $tag['type']) {
55+
return new StateMachineValidator();
6956
}
7057

71-
if (empty($this->validators[$name])) {
72-
$this->validators[$name] = new $class();
58+
if ('single_state' === $tag['marking_store']) {
59+
return new WorkflowValidator(true);
7360
}
7461

75-
return $this->validators[$name];
62+
return new WorkflowValidator();
7663
}
7764
}

0 commit comments

Comments
 (0)