Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Workflow] Added more events to the announce function #23299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make sure the events are dispatched in the correct order
  • Loading branch information
Nyholm committed Jun 26, 2017
commit 30728d999c4f579dff052e61da5587f34bd76b6e
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Workflow/Tests/WorkflowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,11 +263,11 @@ public function testApplyWithEventDispatcher()
'workflow.workflow_name.entered.b',
'workflow.workflow_name.entered.c',
// Following events are fired because of announce() method
'workflow.announce',
'workflow.workflow_name.announce',
'workflow.guard',
'workflow.workflow_name.guard',
'workflow.workflow_name.guard.t2',
'workflow.announce',
'workflow.workflow_name.announce',
'workflow.workflow_name.announce.t2',
);

Expand Down
9 changes: 6 additions & 3 deletions 9 src/Symfony/Component/Workflow/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,13 @@ private function announce($subject, Transition $initialTransition, Marking $mark

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

$this->dispatcher->dispatch('workflow.announce', $event);
$this->dispatcher->dispatch(sprintf('workflow.%s.announce', $this->name), $event);

$eventsDispatched = false;
foreach ($this->getEnabledTransitions($subject) as $transition) {
if (!$eventsDispatched) {
$this->dispatcher->dispatch('workflow.announce', $event);
$this->dispatcher->dispatch(sprintf('workflow.%s.announce', $this->name), $event);
$eventsDispatched = true;
}
$this->dispatcher->dispatch(sprintf('workflow.%s.announce.%s', $this->name, $transition->getName()), $event);
}
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.