diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index 7f47411d0ba7b..ee76f128cbe4d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -18,6 +18,7 @@
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
+use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\Form\Form;
use Symfony\Component\Lock\Lock;
use Symfony\Component\Lock\Store\SemaphoreStore;
@@ -266,10 +267,22 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
$workflows = $v;
unset($workflows['enabled']);
- if (1 === \count($workflows) && isset($workflows[0]['enabled'])) {
+ if (1 === \count($workflows) && isset($workflows[0]['enabled']) && 1 === \count($workflows[0])) {
$workflows = array();
}
+ if (1 === \count($workflows) && isset($workflows['workflows']) && array_keys($workflows['workflows']) !== range(0, \count($workflows) - 1) && !empty(array_diff(array_keys($workflows['workflows']), array('audit_trail', 'type', 'marking_store', 'supports', 'support_strategy', 'initial_place', 'places', 'transitions')))) {
+ $workflows = $workflows['workflows'];
+ }
+
+ foreach ($workflows as $key => $workflow) {
+ if (isset($workflow['enabled']) && false === $workflow['enabled']) {
+ throw new LogicException(sprintf('Cannot disable a single workflow. Remove the configuration for the workflow "%s" instead.', $workflow['name']));
+ }
+
+ unset($workflows[$key]['enabled']);
+ }
+
$v = array(
'enabled' => true,
'workflows' => $workflows,
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php
new file mode 100644
index 0000000000000..16009b588fff7
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled.php
@@ -0,0 +1,19 @@
+loadFromExtension('framework', array(
+ 'workflows' => array(
+ 'enabled' => true,
+ 'foo' => array(
+ 'type' => 'workflow',
+ 'supports' => array('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'),
+ 'initial_place' => 'bar',
+ 'places' => array('bar', 'baz'),
+ 'transitions' => array(
+ 'bar_baz' => array(
+ 'from' => array('foo'),
+ 'to' => array('bar'),
+ ),
+ ),
+ ),
+ ),
+));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php
new file mode 100644
index 0000000000000..bd36d87fa2570
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows_explicitly_enabled_named_workflows.php
@@ -0,0 +1,19 @@
+loadFromExtension('framework', array(
+ 'workflows' => array(
+ 'enabled' => true,
+ 'workflows' => array(
+ 'type' => 'workflow',
+ 'supports' => array('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'),
+ 'initial_place' => 'bar',
+ 'places' => array('bar', 'baz'),
+ 'transitions' => array(
+ 'bar_baz' => array(
+ 'from' => array('foo'),
+ 'to' => array('bar'),
+ ),
+ ),
+ ),
+ ),
+));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml
new file mode 100644
index 0000000000000..a73b553c49568
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+ Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ bar
+ baz
+
+ bar
+ baz
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml
new file mode 100644
index 0000000000000..4b430d9115b34
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows_explicitly_enabled_named_workflows.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+ Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ bar
+ baz
+
+ bar
+ baz
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml
new file mode 100644
index 0000000000000..21abbf03055a4
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled.yml
@@ -0,0 +1,16 @@
+framework:
+ workflows:
+ enabled: true
+ workflows:
+ foo:
+ type: workflow
+ supports:
+ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ initial_place: bar
+ places:
+ - bar
+ - baz
+ transitions:
+ bar_baz:
+ from: [foo]
+ to: [bar]
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml
new file mode 100644
index 0000000000000..a6c03de95d1b3
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows_explicitly_enabled_named_workflows.yml
@@ -0,0 +1,15 @@
+framework:
+ workflows:
+ enabled: true
+ workflows:
+ type: workflow
+ supports:
+ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ initial_place: bar
+ places:
+ - bar
+ - baz
+ transitions:
+ bar_baz:
+ from: [foo]
+ to: [bar]
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 06e709c5ca3a8..07fc026397d7b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -320,6 +320,20 @@ public function testWorkflowServicesCanBeEnabled()
$this->assertTrue($container->hasDefinition('console.command.workflow_dump'));
}
+ public function testExplicitlyEnabledWorkflows()
+ {
+ $container = $this->createContainerFromFile('workflows_explicitly_enabled');
+
+ $this->assertTrue($container->hasDefinition('workflow.foo.definition'));
+ }
+
+ public function testExplicitlyEnabledWorkflowNamedWorkflows()
+ {
+ $container = $this->createContainerFromFile('workflows_explicitly_enabled_named_workflows');
+
+ $this->assertTrue($container->hasDefinition('workflow.workflows.definition'));
+ }
+
public function testEnabledPhpErrorsConfig()
{
$container = $this->createContainerFromFile('php_errors_enabled');