8000 bug #28769 [FrameworkBundle] deal with explicitly enabled workflow no… · symfony/symfony@b74a086 · GitHub
[go: up one dir, main page]

Skip to content

Commit b74a086

Browse files
committed
bug #28769 [FrameworkBundle] deal with explicitly enabled workflow nodes (xabbuh)
This PR was merged into the 3.4 branch. Discussion ---------- [FrameworkBundle] deal with explicitly enabled workflow nodes | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | not yet | Fixed tickets | #28662 | License | MIT | Doc PR | Commits ------- 017fd56 deal with explicitly enabled workflow nodes
2 parents 236565c + 017fd56 commit b74a086

8 files changed

+135
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
1919
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
2020
use Symfony\Component\Config\Definition\ConfigurationInterface;
21+
use Symfony\Component\DependencyInjection\Exception\LogicException;
2122
use Symfony\Component\Form\Form;
2223
use Symfony\Component\Lock\Lock;
2324
use Symfony\Component\Lock\Store\SemaphoreStore;
@@ -267,10 +268,22 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
267268
$workflows = $v;
268269
unset($workflows['enabled']);
269270

270-
if (1 === \count($workflows) && isset($workflows[0]['enabled'])) {
271+
if (1 === \count($workflows) && isset($workflows[0]['enabled']) && 1 === \count($workflows[0])) {
271272
$workflows = array();
272273
}
273274

275+
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')))) {
276+
$workflows = $workflows['workflows'];
277+
}
278+
279+
foreach ($workflows as $key => $workflow) {
280+
if (isset($workflow['enabled']) && false === $workflow['enabled']) {
281+
throw new LogicException(sprintf('Cannot disable a single workflow. Remove the configuration for the workflow "%s" instead.', $workflow['name']));
282+
}
283+
284+
unset($workflows[$key]['enabled']);
285+
}
286+
274287
$v = array(
275288
'enabled' => true,
276289
'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
@@ -390,6 +390,20 @@ public function testWorkflowServicesCanBeEnabled()
390390
$this->assertTrue($container->hasDefinition('console.command.workflow_dump'));
391391
}
392392

393+
public function testExplicitlyEnabledWorkflows()
394+
{
395+
$container = $this->createContainerFromFile('workflows_explicitly_enabled');
396+
397+
$this->assertTrue($container->hasDefinition('workflow.foo.definition'));
398+
}
399+
400+
public function testExplicitlyEnabledWorkflowNamedWorkflows()
401+
{
402+
$container = $this->createContainerFromFile('workflows_explicitly_enabled_named_workflows');
403+
404+
$this->assertTrue($container->hasDefinition('workflow.workflows.definition'));
405+
}
406+
393407
public function testEnabledPhpErrorsConfig()
394408
{
395409
$container = $this->createContainerFromFile('php_errors_enabled');

0 commit comments

Comments
 (0)
0