bug #28007 [FrameworkBundle] fixed guard event names for transitions (destillat)

This PR was submitted for the 3.3 branch but it was merged into the 3.4 branch instead (closes #28007).

Discussion
----------

[FrameworkBundle] fixed guard event names for transitions

| Q             | A
| ------------- | ---
| Branch?       | 3.3|4
| Bug fix?      | yes
| New feature?  |no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

Framework yaml configuration support workflow transitions as both indexed and associative array e.g
```yaml
transitions:
    -    name: test
         from: open
         to: test
    -
```
```yaml
transitions:
    test:
         from: open
         to: test
```
Then it's used in foreach loop to register guard event listeners 4b92b96796/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php (L609)
Array keys are used as transition names but it's wrong for indexed array so we get event names like these
workflow.workflow_name.guard.transition_index instead of workflow.workflow_name.guard.tranision_name

Commits
-------

9bbb1e5cff [FrameworkBundle] fixed guard event names for transitions
This commit is contained in:
Nicolas Grekas 2018-07-29 17:24:27 +02:00
commit 4081bc6a50
1 changed files with 3 additions and 1 deletions

View File

@ -679,7 +679,9 @@ class FrameworkExtension extends Extension
$guard = new Definition(Workflow\EventListener\GuardListener::class);
$guard->setPrivate(true);
$configuration = array();
foreach ($workflow['transitions'] as $transitionName => $config) {
foreach ($workflow['transitions'] as $config) {
$transitionName = $config['name'];
if (!isset($config['guard'])) {
continue;
}