Skip to content

[FrameworkBundle] be able to enable workflow support explicitly #24093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
250 changes: 137 additions & 113 deletions src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,13 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
/**
* Loads the workflow configuration.
*
* @param array $workflows A workflow configuration array
* @param array $config A workflow configuration array
* @param ContainerBuilder $container A ContainerBuilder instance
* @param XmlFileLoader $loader An XmlFileLoader instance
*/
private function registerWorkflowConfiguration(array $workflows, ContainerBuilder $container, XmlFileLoader $loader)
private function registerWorkflowConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
{
if (!$workflows) {
if (!$config['enabled']) {
if (!class_exists(Workflow\Workflow::class)) {
$container->removeDefinition(WorkflowDumpCommand::class);
}
Expand All @@ -552,7 +552,7 @@ private function registerWorkflowConfiguration(array $workflows, ContainerBuilde

$registryDefinition = $container->getDefinition('workflow.registry');

foreach ($workflows as $name => $workflow) {
foreach ($config['workflows'] as $name => $workflow) {
if (!array_key_exists('type', $workflow)) {
$workflow['type'] = 'workflow';
@trigger_error(sprintf('The "type" option of the "framework.workflows.%s" configuration entry must be defined since Symfony 3.3. The default value will be "state_machine" in Symfony 4.0.', $name), E_USER_DEPRECATED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,16 @@

<xsd:complexType name="workflow">
<xsd:sequence>
<xsd:element name="marking-store" type="marking_store" />
<xsd:element name="marking-store" type="marking_store" minOccurs="0" maxOccurs="1" />
<xsd:element name="support" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="place" type="xsd:string" minOccurs="1" maxOccurs="unbounded" />
<xsd:element name="transition" type="transition" minOccurs="1" maxOccurs="unbounded" />
<xsd:element name="place" type="xsd:string" minOccurs="0" maxOccurs="unbounded" />
<xsd:element name="transition" type="transition" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="workflow_type" />
<xsd:attribute name="initial-place" type="xsd:string" />
<xsd:attribute name="support-strategy" type="xsd:string" />
<xsd:attribute name="enabled" type="xsd:boolean" />
</xsd:complexType>

<xsd:complexType name="marking_store">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ protected static function getBundleDefaultConfig()
'default_redis_provider' => 'redis://localhost',
'default_memcached_provider' => 'memcached://localhost',
),
'workflows' => array(),
'workflows' => array(
'enabled' => false,
'workflows' => array(),
),
'php_errors' => array(
'log' => true,
'throw' => true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

$container->loadFromExtension('framework', array(
'workflows' => null,
));
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">

<framework:config>
<framework:workflow enabled="true" />
</framework:config>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
framework:
workflows: ~
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;

use Doctrine\Common\Annotations\Annotation;
use Symfony\Bundle\FrameworkBundle\Command\WorkflowDumpCommand;
use Symfony\Bundle\FullStack;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddAnnotationsCachedReaderPass;
Expand Down Expand Up @@ -42,6 +43,7 @@
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
use Symfony\Component\Workflow\Registry;

abstract class FrameworkExtensionTest extends TestCase
{
Expand Down Expand Up @@ -307,6 +309,14 @@ public function testWorkflowMultipleTransitionsWithSameName()
$this->assertSame(array('draft'), $transitions[4]->getArgument(1));
}

public function testWorkflowServicesCanBeEnabled()
{
$container = $this->createContainerFromFile('workflows_enabled');

$this->assertTrue($container->has(Registry::class));
$this->assertTrue($container->hasDefinition(WorkflowDumpCommand::class));
}

public function testRouter()
{
$container = $this->createContainerFromFile('full');
Expand Down