Skip to content

Commit a42d1ab

Browse files
Merge branch '3.4' into 4.1
* 3.4: fix cs SCA: consolidate non empty array checks across codebase [cs] correct invalid @param types [Bridge/PhpUnit] Use composer to download phpunit [DI] fix taking lazy services into account when dumping the container [Form] Fixed empty data for compound date interval [Cache] fix optimizing Psr6Cache for AdapterInterface pools deal with explicitly enabled workflow nodes
2 parents 3d18f0a + 1c1f86b commit a42d1ab

8 files changed

+135
-1
lines changed

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;
@@ -220,10 +221,22 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
220221
$workflows = $v;
221222
unset($workflows['enabled']);
222223

223-
if (1 === \count($workflows) && isset($workflows[0]['enabled'])) {
224+
if (1 === \count($workflows) && isset($workflows[0]['enabled']) && 1 === \count($workflows[0])) {
224225
$workflows = array();
225226
}
226227

228+
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')))) {
229+
$workflows = $workflows['workflows'];
230+
}
231+
232+
foreach ($workflows as $key => $workflow) {
233+
if (isset($workflow['enabled']) && false === $workflow['enabled']) {
234+
throw new LogicException(sprintf('Cannot disable a single workflow. Remove the configuration for the workflow "%s" instead.', $workflow['name']));
235+
}
236+
237+
unset($workflows[$key]['enabled']);
238+
}
239+
227240
$v = array(
228241
'enabled' => true,
229242
'workflows' => $workflows,
Lines changed: 19 additions & 0 deletions
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+
));
Lines changed: 19 additions & 0 deletions
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+
));
Lines changed: 19 additions & 0 deletions
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>
Lines changed: 19 additions & 0 deletions
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>
Lines changed: 16 additions & 0 deletions
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]
Lines changed: 15 additions & 0 deletions
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]

Tests/DependencyInjection/FrameworkExtensionTest.php

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

412+
public function testExplicitlyEnabledWorkflows()
413+
{
414+
$container = $this->createContainerFromFile('workflows_explicitly_enabled');
415+
416+
$this->assertTrue($container->hasDefinition('workflow.foo.definition'));
417+
}
418+
419+
public function testExplicitlyEnabledWorkflowNamedWorkflows()
420+
{
421+
$container = $this->createContainerFromFile('workflows_explicitly_enabled_named_workflows');
422+
423+
$this->assertTrue($container->hasDefinition('workflow.workflows.definition'));
424+
}
425+
412426
public function testEnabledPhpErrorsConfig()
413427
{
414428
$container = $this->createContainerFromFile('php_errors_enabled');

0 commit comments

Comments
 (0)