Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cfc3c30

Browse files
committed
deal with explicitly enabled workflow nodes
1 parent 155fab6 commit cfc3c30

8 files changed

+126
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,14 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
266266
$workflows = $v;
267267
unset($workflows['enabled']);
268268

269-
if (1 === \count($workflows) && isset($workflows[0]['enabled'])) {
269+
if (1 === \count($workflows) && isset($workflows[0]['enabled']) && 1 === \count($workflows[0])) {
270270
$workflows = array();
271271
}
272272

273+
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')))) {
274+
$workflows = $workflows['workflows'];
275+
}
276+
273277
$v = array(
274278
'enabled' => true,
275279
'workflows' => $workflows,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'workflows' => array(
5+
'enabled' => true,
6+
'foo' => array(
7+
'type' => 'workflow',
8+
'supports' => array('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'),
9+
'initial_place' => 'bar',
10+
'places' => array('bar', 'baz'),
11+
'transitions' => array(
12+
'bar_baz' => array(
13+
'from' => array('foo'),
14+
'to' => array('bar'),
15+
),
16+
),
17+
),
18+
),
19+
));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'workflows' => array(
5+
'enabled' => true,
6+
'workflows' => array(
7+
'type' => 'workflow',
8+
'supports' => array('Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest'),
9+
'initial_place' => 'bar',
10+
'places' => array('bar', 'baz'),
11+
'transitions' => array(
12+
'bar_baz' => array(
13+
'from' => array('foo'),
14+
'to' => array('bar'),
15+
),
16+
),
17+
),
18+
),
19+
));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:workflow enabled="true" name="foo" type="workflow" initial-place="bar">
10+
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
11+
<framework:place>bar</framework:place>
12+
<framework:place>baz</framework:place>
13+
<framework:transition name="bar_baz">
14+
<framework:from>bar</framework:from>
15+
<framework:to>baz</framework:to>
16+
</framework:transition>
17+
</framework:workflow>
18+
</framework:config>
19+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:workflow enabled="true" name="workflows" type="workflow" initial-place="bar">
10+
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support>
11+
<framework:place>bar</framework:place>
12+
<framework:place>baz</framework:place>
13+
<framework:transition name="bar_baz">
14+
<framework:from>bar</framework:from>
15+
<framework:to>baz</framework:to>
16+
</framework:transition>
17+
</framework:workflow>
18+
</framework:config>
19+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
framework:
2+
workflows:
3+
enabled: true
4+
workflows:
5+
foo:
6+
type: workflow
7+
supports:
8+
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
9+
initial_place: bar
10+
places:
11+
- bar
12+
- baz
13+
transitions:
14+
bar_baz:
15+
from: [foo]
16+
to: [bar]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
framework:
2+
workflows:
3+
enabled: true
4+
workflows:
5+
type: workflow
6+
supports:
7+
- Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest
8+
initial_place: bar
9+
places:
10+
- bar
11+
- baz
12+
transitions:
13+
bar_baz:
14+
from: [foo]
15+
to: [bar]

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,20 @@ public function testWorkflowServicesCanBeEnabled()
320320
$this->assertTrue($container->hasDefinition('console.command.workflow_dump'));
321321
}
322322

323+
public function testExplicitlyEnabledWorkflows()
324+
{
325+
$container = $this->createContainerFromFile('workflows_explicitly_enabled');
326+
327+
$this->assertTrue($container->hasDefinition('workflow.foo.definition'));
328+
}
329+
330+
public function testExplicitlyEnabledWorkflowNamedWorkflows()
331+
{
332+
$container = $this->createContainerFromFile('workflows_explicitly_enabled_named_workflows');
333+
334+
$this->assertTrue($container->hasDefinition('workflow.workflows.definition'));
335+
}
336+
323337
public function testEnabledPhpErrorsConfig()
324338
{
325339
$container = $this->createContainerFromFile('php_errors_enabled');

0 commit comments

Comments
 (0)