[FrameworkBundle] changed configuration file for workflow from XML to PHP

This commit is contained in:
Grégoire Pineau 2020-06-22 16:26:03 +02:00
parent b3a313cd35
commit 2f1b72d7d0
3 changed files with 49 additions and 33 deletions

View File

@ -372,7 +372,7 @@ class FrameworkExtension extends Extension
$this->registerFragmentsConfiguration($config['fragments'], $container, $phpLoader);
$this->registerTranslatorConfiguration($config['translator'], $container, $phpLoader, $config['default_locale']);
$this->registerProfilerConfiguration($config['profiler'], $container, $loader, $phpLoader);
$this->registerWorkflowConfiguration($config['workflows'], $container, $loader);
$this->registerWorkflowConfiguration($config['workflows'], $container, $phpLoader);
$this->registerDebugConfiguration($config['php_errors'], $container, $phpLoader);
$this->registerRouterConfiguration($config['router'], $container, $phpLoader, $config['translator']['enabled_locales'] ?? []);
$this->registerAnnotationsConfiguration($config['annotations'], $container, $phpLoader);
@ -639,7 +639,7 @@ class FrameworkExtension extends Extension
->addTag('kernel.reset', ['method' => 'reset']);
}
private function registerWorkflowConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
private function registerWorkflowConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader)
{
if (!$config['enabled']) {
$container->removeDefinition('console.command.workflow_dump');
@ -651,7 +651,7 @@ class FrameworkExtension extends Extension
throw new LogicException('Workflow support cannot be enabled as the Workflow component is not installed. Try running "composer require symfony/workflow".');
}
$loader->load('workflow.xml');
$loader->load('workflow.php');
$registryDefinition = $container->getDefinition('workflow.registry');

View File

@ -0,0 +1,46 @@
<?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\DependencyInjection\Loader\Configurator;
use Symfony\Component\Workflow\EventListener\ExpressionLanguage;
use Symfony\Component\Workflow\MarkingStore\MethodMarkingStore;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\StateMachine;
use Symfony\Component\Workflow\Workflow;
return static function (ContainerConfigurator $container) {
$container->services()
->set('workflow.abstract', Workflow::class)
->args([
abstract_arg('workflow definition'),
abstract_arg('marking store'),
service('event_dispatcher')->ignoreOnInvalid(),
abstract_arg('workflow name'),
])
->abstract()
->public()
->set('state_machine.abstract', StateMachine::class)
->args([
abstract_arg('workflow definition'),
abstract_arg('marking store'),
service('event_dispatcher')->ignoreOnInvalid(),
abstract_arg('workflow name'),
])
->abstract()
->public()
->set('workflow.marking_store.method', MethodMarkingStore::class)
->abstract()
->set('workflow.registry', Registry::class)
->alias(Registry::class, 'workflow.registry')
->set('workflow.security.expression_language', ExpressionLanguage::class)
;
};

View File

@ -1,30 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults public="false" />
<service id="workflow.abstract" class="Symfony\Component\Workflow\Workflow" abstract="true" public="true">
<argument /> <!-- workflow definition -->
<argument type="constant">null</argument> <!-- marking store -->
<argument type="service" id="event_dispatcher" on-invalid="ignore" />
<argument /> <!-- name -->
</service>
<service id="state_machine.abstract" class="Symfony\Component\Workflow\StateMachine" abstract="true" public="true">
<argument /> <!-- workflow definition -->
<argument type="constant">null</argument> <!-- marking store -->
<argument type="service" id="event_dispatcher" on-invalid="ignore" />
<argument /> <!-- name -->
</service>
<service id="workflow.marking_store.method" class="Symfony\Component\Workflow\MarkingStore\MethodMarkingStore" abstract="true" />
<service id="workflow.registry" class="Symfony\Component\Workflow\Registry" />
<service id="Symfony\Component\Workflow\Registry" alias="workflow.registry" />
<service id="workflow.security.expression_language" class="Symfony\Component\Workflow\EventListener\ExpressionLanguage" />
</services>
</container>