diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
index df59ea87e7..ed97fb518d 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
@@ -231,16 +231,21 @@ class Configuration implements ConfigurationInterface
private function addWorkflowSection(ArrayNodeDefinition $rootNode)
{
$rootNode
+ ->fixXmlConfig('workflow')
->children()
->arrayNode('workflows')
->useAttributeAsKey('name')
->prototype('array')
+ ->fixXmlConfig('support')
+ ->fixXmlConfig('place')
+ ->fixXmlConfig('transition')
->children()
->enumNode('type')
->values(array('workflow', 'state_machine'))
->defaultValue('workflow')
->end()
->arrayNode('marking_store')
+ ->fixXmlConfig('argument')
->children()
->enumNode('type')
->values(array('multiple_state', 'single_state'))
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
index b37f87007d..fbf53309f4 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd
@@ -8,7 +8,7 @@
-
+
@@ -26,8 +26,8 @@
-
-
+
+
@@ -228,42 +228,45 @@
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow.php
deleted file mode 100644
index 222299a9c0..0000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow.php
+++ /dev/null
@@ -1,30 +0,0 @@
-loadFromExtension('framework', array(
- 'workflows' => array(
- 'my_workflow' => array(
- 'marking_store' => array(
- 'type' => 'multiple_state',
- ),
- 'supports' => array(
- FrameworkExtensionTest::class,
- ),
- 'places' => array(
- 'first',
- 'last',
- ),
- 'transitions' => array(
- 'go' => array(
- 'from' => array(
- 'first',
- ),
- 'to' => array(
- 'last',
- ),
- ),
- ),
- ),
- ),
-));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php
new file mode 100644
index 0000000000..854a858415
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflows.php
@@ -0,0 +1,92 @@
+loadFromExtension('framework', array(
+ 'workflows' => array(
+ 'article' => array(
+ 'type' => 'workflow',
+ 'marking_store' => array(
+ 'type' => 'multiple_state',
+ ),
+ 'supports' => array(
+ FrameworkExtensionTest::class,
+ ),
+ 'initial_place' => 'draft',
+ 'places' => array(
+ 'draft',
+ 'wait_for_journalist',
+ 'approved_by_journalist',
+ 'wait_for_spellchecker',
+ 'approved_by_spellchecker',
+ 'published',
+ ),
+ 'transitions' => array(
+ 'request_review' => array(
+ 'from' => 'draft',
+ 'to' => array('wait_for_journalist', 'wait_for_spellchecker'),
+ ),
+ 'journalist_approval' => array(
+ 'from' => 'wait_for_journalist',
+ 'to' => 'approved_by_journalist',
+ ),
+ 'spellchecker_approval' => array(
+ 'from' => 'wait_for_spellchecker',
+ 'to' => 'approved_by_spellchecker',
+ ),
+ 'publish' => array(
+ 'from' => array('approved_by_journalist', 'approved_by_spellchecker'),
+ 'to' => 'published',
+ ),
+ ),
+ ),
+ 'pull_request' => array(
+ 'type' => 'state_machine',
+ 'marking_store' => array(
+ 'type' => 'single_state',
+ ),
+ 'supports' => array(
+ FrameworkExtensionTest::class,
+ ),
+ 'initial_place' => 'start',
+ 'places' => array(
+ 'start',
+ 'coding',
+ 'travis',
+ 'review',
+ 'merged',
+ 'closed',
+ ),
+ 'transitions' => array(
+ 'submit' => array(
+ 'from' => 'start',
+ 'to' => 'travis',
+ ),
+ 'update' => array(
+ 'from' => array('coding', 'travis', 'review'),
+ 'to' => 'travis',
+ ),
+ 'wait_for_review' => array(
+ 'from' => 'travis',
+ 'to' => 'review',
+ ),
+ 'request_change' => array(
+ 'from' => 'review',
+ 'to' => 'coding',
+ ),
+ 'accept' => array(
+ 'from' => 'review',
+ 'to' => 'merged',
+ ),
+ 'reject' => array(
+ 'from' => 'review',
+ 'to' => 'closed',
+ ),
+ 'reopen' => array(
+ 'from' => 'closed',
+ 'to' => 'review',
+ ),
+ ),
+ ),
+ ),
+));
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow.xml
deleted file mode 100644
index 447b390f24..0000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
- multiple_state
- a
- a
-
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
- first
- last
-
-
- a
- a
-
-
-
-
-
-
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml
new file mode 100644
index 0000000000..924ff75111
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflows.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+ a
+ a
+
+ Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ draft
+ wait_for_journalist
+ approved_by_journalist
+ wait_for_spellchecker
+ approved_by_spellchecker
+ published
+
+ draft
+ wait_for_journalist
+ wait_for_spellchecker
+
+
+ wait_for_journalist
+ approved_by_journalist
+
+
+ wait_for_spellcheker
+ approved_by_spellchker
+
+
+ approved_by_journalist
+ approved_by_spellchker
+ published
+
+
+
+
+
+ Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ start
+ coding
+ travis
+ review
+ merged
+ closed
+
+ start
+ travis
+
+
+ coding
+ travis
+ review
+ travis
+
+
+ travis
+ review
+
+
+ review
+ coding
+
+
+ review
+ merged
+
+
+ review
+ closed
+
+
+ closed
+ review
+
+
+
+
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow.yml
deleted file mode 100644
index 2bd071e568..0000000000
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-framework:
- workflows:
- my_workflow:
- marking_store:
- type: multiple_state
- supports:
- - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
- places:
- - first
- - last
- transitions:
- go:
- from:
- - first
- to:
- - last
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml
new file mode 100644
index 0000000000..a933db5100
--- /dev/null
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflows.yml
@@ -0,0 +1,65 @@
+framework:
+ workflows:
+ article:
+ type: workflow
+ marking_store:
+ type: multiple_state
+ supports:
+ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ initial_place: draft
+ places:
+ - draft
+ - wait_for_journalist
+ - approved_by_journalist
+ - wait_for_spellchecker
+ - approved_by_spellchecker
+ - published
+ transitions:
+ request_review:
+ from: [draft]
+ to: [wait_for_journalist, wait_for_spellchecker]
+ journalist_approval:
+ from: [wait_for_journalist]
+ to: [approved_by_journalist]
+ spellchecker_approval:
+ from: [wait_for_spellchecker]
+ to: [approved_by_spellchecker]
+ publish:
+ from: [approved_by_journalist, approved_by_spellchecker]
+ to: [published]
+ pull_request:
+ type: state_machine
+ marking_store:
+ type: single_state
+ supports:
+ - Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
+ initial_place: start
+ places:
+ - start
+ - coding
+ - travis
+ - review
+ - merged
+ - closed
+ transitions:
+ submit:
+ from: start
+ to: travis
+ update:
+ from: [coding, travis, review]
+ to: travis
+ wait_for_review:
+ from: travis
+ to: review
+ request_change:
+ from: review
+ to: coding
+ accept:
+ from: review
+ to: merged
+ reject:
+ from: review
+ to: closed
+ reopen:
+ from: closed
+ to: review
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
index 18a4829802..2a0aa0196f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
@@ -120,11 +120,51 @@ abstract class FrameworkExtensionTest extends TestCase
$this->assertFalse($container->hasDefinition('data_collector.config'), '->registerProfilerConfiguration() does not load collectors.xml');
}
- public function testWorkflow()
+ public function testWorkflows()
{
- $container = $this->createContainerFromFile('workflow');
+ $container = $this->createContainerFromFile('workflows');
- $this->assertTrue($container->hasDefinition('workflow.my_workflow'));
+ $this->assertTrue($container->hasDefinition('workflow.article', 'Workflow is registered as a service'));
+ $this->assertTrue($container->hasDefinition('workflow.article.definition', 'Workflow definition is registered as a service'));
+
+ $workflowDefinition = $container->getDefinition('workflow.article.definition');
+
+ $this->assertSame(
+ array(
+ 'draft',
+ 'wait_for_journalist',
+ 'approved_by_journalist',
+ 'wait_for_spellchecker',
+ 'approved_by_spellchecker',
+ 'published',
+ ),
+ $workflowDefinition->getArgument(0),
+ 'Places are passed to the workflow definition'
+ );
+ $this->assertSame(array('workflow.definition' => array(array('name' => 'article', 'type' => 'workflow', 'marking_store' => 'multiple_state'))), $workflowDefinition->getTags());
+
+ $this->assertTrue($container->hasDefinition('state_machine.pull_request', 'State machine is registered as a service'));
+ $this->assertTrue($container->hasDefinition('state_machine.pull_request.definition', 'State machine definition is registered as a service'));
+ $this->assertCount(4, $workflowDefinition->getArgument(1));
+ $this->assertSame('draft', $workflowDefinition->getArgument(2));
+
+ $stateMachineDefinition = $container->getDefinition('state_machine.pull_request.definition');
+
+ $this->assertSame(
+ array(
+ 'start',
+ 'coding',
+ 'travis',
+ 'review',
+ 'merged',
+ 'closed',
+ ),
+ $stateMachineDefinition->getArgument(0),
+ 'Places are passed to the state machine definition'
+ );
+ $this->assertSame(array('workflow.definition' => array(array('name' => 'pull_request', 'type' => 'state_machine', 'marking_store' => 'single_state'))), $stateMachineDefinition->getTags());
+ $this->assertCount(9, $stateMachineDefinition->getArgument(1));
+ $this->assertSame('start', $stateMachineDefinition->getArgument(2));
}
public function testRouter()