1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* (c) 2019, Wesley O. Nichols |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Wesnick\WorkflowBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\FileLocator; |
15
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
16
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
17
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
18
|
|
|
use Wesnick\WorkflowBundle\Validation\ChainedWorkflowValidationStrategy; |
19
|
|
|
use Wesnick\WorkflowBundle\Validation\ValidationStateProviderStrategy; |
20
|
|
|
use Wesnick\WorkflowBundle\Validation\WorkflowValidationStrategy; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* {@inheritdoc} |
24
|
|
|
*/ |
25
|
|
|
class WesnickWorkflowExtension extends Extension |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* {@inheritdoc} |
29
|
|
|
*/ |
30
|
|
|
public function load(array $configs, ContainerBuilder $container) |
31
|
|
|
{ |
32
|
|
|
$configuration = new Configuration(); |
33
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
34
|
|
|
|
35
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
36
|
|
|
$loader->load('workflow.xml'); |
37
|
|
|
if (true === $config['api_patch_transitions']) { |
38
|
|
|
$loader->load('api_patch.xml'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
if (true === $config['workflow_validation_guard']) { |
42
|
|
|
$loader->load('workflow_validation.xml'); |
43
|
|
|
// @TODO: add a tag |
44
|
|
|
$chainedValidator = $container->getDefinition(ChainedWorkflowValidationStrategy::class); |
45
|
|
|
$chainedValidator->setArgument(0, [ |
46
|
|
|
$container->getDefinition(WorkflowValidationStrategy::class), |
47
|
|
|
$container->getDefinition(ValidationStateProviderStrategy::class) |
48
|
|
|
]); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|