Skip to content

Commit 25ab339

Browse files
committed
bug symfony#23299 [Workflow] Added more events to the announce function (Nyholm)
This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes symfony#23299). Discussion ---------- [Workflow] Added more events to the announce function | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes/no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#23275 | License | MIT | Doc PR | symfony#8087 This PR will fix symfony#23275 The documentation states that we dispatch events `workflow.announce` and `workflow.[name].announce`. It was me who wrongly added it to the docs... sorry about that. We could either: Change the docs or add these events. I choose to add these event to the source since the same events are dispatched for "guard", "leave", "transition", "enter" and "entered". Commits ------- c5042f3 [Workflow] Added more events to the announce function
2 parents 59094b4 + c5042f3 commit 25ab339

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Symfony/Component/Workflow/Tests/WorkflowTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ public function testApplyWithEventDispatcher()
259259
'workflow.workflow_name.enter.b',
260260
'workflow.workflow_name.enter.c',
261261
// Following events are fired because of announce() method
262+
'workflow.announce',
263+
'workflow.workflow_name.announce',
262264
'workflow.guard',
263265
'workflow.workflow_name.guard',
264266
'workflow.workflow_name.guard.t2',

src/Symfony/Component/Workflow/Workflow.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ private function announce($subject, Transition $initialTransition, Marking $mark
282282

283283
$event = new Event($subject, $marking, $initialTransition);
284284

285+
$this->dispatcher->dispatch('workflow.announce', $event);
286+
$this->dispatcher->dispatch(sprintf('workflow.%s.announce', $this->name), $event);
287+
285288
foreach ($this->getEnabledTransitions($subject) as $transition) {
286289
$this->dispatcher->dispatch(sprintf('workflow.%s.announce.%s', $this->name, $transition->getName()), $event);
287290
}

0 commit comments

Comments
 (0)