feature #20787 [Workflow] Added an entered event (Padam87)
This PR was submitted for the 3.2 branch but it was merged into the 3.3-dev branch instead (closes #20787).
Discussion
----------
[Workflow] Added an entered event
| Q | A
| ------------- | ---
| Branch? | 3.2
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #20774 (partially) ; #21433
| License | MIT
| Doc PR | -
Commits
-------
7a562bd81e
[Workflow] Added an entered event
This commit is contained in:
commit
772d8e6066
@ -239,6 +239,10 @@ class WorkflowTest extends \PHPUnit_Framework_TestCase
|
||||
'workflow.workflow_name.enter',
|
||||
'workflow.workflow_name.enter.b',
|
||||
'workflow.workflow_name.enter.c',
|
||||
'workflow.entered',
|
||||
'workflow.workflow_name.entered',
|
||||
'workflow.workflow_name.entered.b',
|
||||
'workflow.workflow_name.entered.c',
|
||||
// Following events are fired because of announce() method
|
||||
'workflow.guard',
|
||||
'workflow.workflow_name.guard',
|
||||
|
@ -140,6 +140,8 @@ class Workflow
|
||||
|
||||
$this->markingStore->setMarking($subject, $marking);
|
||||
|
||||
$this->entered($subject, $transition, $marking);
|
||||
|
||||
$this->announce($subject, $transition, $marking);
|
||||
}
|
||||
|
||||
@ -270,6 +272,22 @@ class Workflow
|
||||
}
|
||||
}
|
||||
|
||||
private function entered($subject, Transition $transition, Marking $marking)
|
||||
{
|
||||
if (null === $this->dispatcher) {
|
||||
return;
|
||||
}
|
||||
|
||||
$event = new Event($subject, $marking, $transition);
|
||||
|
||||
$this->dispatcher->dispatch('workflow.entered', $event);
|
||||
$this->dispatcher->dispatch(sprintf('workflow.%s.entered', $this->name), $event);
|
||||
|
||||
foreach ($transition->getTos() as $place) {
|
||||
$this->dispatcher->dispatch(sprintf('workflow.%s.entered.%s', $this->name, $place), $event);
|
||||
}
|
||||
}
|
||||
|
||||
private function announce($subject, Transition $initialTransition, Marking $marking)
|
||||
{
|
||||
if (null === $this->dispatcher) {
|
||||
|
Reference in New Issue
Block a user