Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #29137 [Workflow][FrameworkBundle] fixed guard event names for tr…
…ansitions (destillat, lyrixx) This PR was merged into the 3.4 branch. Discussion ---------- [Workflow][FrameworkBundle] fixed guard event names for transitions | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28018 #28007 (comment) | License | MIT | Doc PR | There is a bug when many transitions are defined with the same name. I finished destillat's work and rebase against 3.4 as it's a bug fix. There another point of failure, but it could not be fixed on 3.4. I will be a need feature. The issue is related to `Workflow::can($subject, $transitionName)`. Since the transitionName could be not unique, we will need to support passing an instance of Transition. A new PR is incomming Commits ------- 83dc473 [FrameworkBundle] fixed guard event names for transitions fb88bfc [FrameworkBundle] fixed guard event names for transitions
- Loading branch information
Showing
9 changed files
with
346 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...FrameworkBundle/Tests/DependencyInjection/Fixtures/php/workflow_with_guard_expression.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
use Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest; | ||
|
||
$container->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', | ||
'guard' => '!!true', | ||
), | ||
'publish_editor_in_chief' => array( | ||
'name' => 'publish', | ||
'from' => 'draft', | ||
'to' => 'published', | ||
'guard' => '!!false', | ||
), | ||
), | ||
), | ||
), | ||
)); |
48 changes: 48 additions & 0 deletions
48
...FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/workflow_with_guard_expression.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<framework:config> | ||
<framework:workflow name="article" type="workflow" initial-place="draft"> | ||
<framework:marking-store type="multiple_state"> | ||
<framework:argument>a</framework:argument> | ||
<framework:argument>a</framework:argument> | ||
</framework:marking-store> | ||
<framework:support>Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\FrameworkExtensionTest</framework:support> | ||
<framework:place>draft</framework:place> | ||
<framework:place>wait_for_journalist</framework:place> | ||
<framework:place>approved_by_journalist</framework:place> | ||
<framework:place>wait_for_spellchecker</framework:place> | ||
<framework:place>approved_by_spellchecker</framework:place> | ||
<framework:place>published</framework:place> | ||
<framework:transition name="request_review"> | ||
<framework:from>draft</framework:from> | ||
<framework:to>wait_for_journalist</framework:to> | ||
<framework:to>wait_for_spellchecker</framework:to> | ||
</framework:transition> | ||
<framework:transition name="journalist_approval"> | ||
<framework:from>wait_for_journalist</framework:from> | ||
<framework:to>approved_by_journalist</framework:to> | ||
</framework:transition> | ||
<framework:transition name="spellchecker_approval"> | ||
<framework:from>wait_for_spellchecker</framework:from> | ||
<framework:to>approved_by_spellchecker</framework:to> | ||
</framework:transition> | ||
<framework:transition name="publish"> | ||
<framework:from>approved_by_journalist</framework:from> | ||
<framework:from>approved_by_spellchecker</framework:from> | ||
<framework:to>published</framework:to> | ||
<framework:guard>!!true</framework:guard> | ||
</framework:transition> | ||
<framework:transition name="publish"> | ||
<framework:from>draft</framework:from> | ||
<framework:to>published</framework:to> | ||
<framework:guard>!!false</framework:guard> | ||
</framework:transition> | ||
</framework:workflow> | ||
</framework:config> | ||
</container> |
35 changes: 35 additions & 0 deletions
35
...FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/workflow_with_guard_expression.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
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] | ||
guard: "!!true" | ||
publish_editor_in_chief: | ||
name: publish | ||
from: [draft] | ||
to: [published] | ||
guard: "!!false" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Symfony/Component/Workflow/EventListener/GuardExpression.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Workflow\EventListener; | ||
|
||
use Symfony\Component\Workflow\Transition; | ||
|
||
class GuardExpression | ||
{ | ||
private $transition; | ||
|
||
private $expression; | ||
|
||
/** | ||
* @param string $expression | ||
*/ | ||
public function __construct(Transition $transition, $expression) | ||
{ | ||
$this->transition = $transition; | ||
$this->expression = $expression; | ||
} | ||
|
||
public function getTransition() | ||
{ | ||
return $this->transition; | ||
} | ||
|
||
public function getExpression() | ||
{ | ||
return $this->expression; | ||
} | ||
} |
Oops, something went wrong.