8000 minor #37813 [Workflow] Simplify code + Updated README.md (lyrixx) · symfony/symfony@3cd1123 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3cd1123

Browse files
committed
minor #37813 [Workflow] Simplify code + Updated README.md (lyrixx)
This PR was merged into the 5.2-dev branch. Discussion ---------- [Workflow] Simplify code + Updated README.md | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #37539 (cleaning previous PR) | License | MIT | Doc PR | Commits ------- 3268bdb [Workflow] Simplify code + Updated README.md
2 parents 684b04b + 3268bdb commit 3cd1123

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/Symfony/Component/Workflow/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ CHANGELOG
66

77
* Added `Workflow::getEnabledTransition()` to easily retrieve a specific transition object
88
* Added context to the event dispatched
9-
* Added default context to the Initial Marking
9+
* Dispatch an event when the subject enters in the workflow for the very first time
10+
* Added a default context to the previous event
1011

1112
5.1.0
1213
-----

src/Symfony/Component/Workflow/Workflow.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,8 @@ private function entered(object $subject, ?Transition $transition, Marking $mark
396396
$this->dispatcher->dispatch($event, WorkflowEvents::ENTERED);
397397
$this->dispatcher->dispatch($event, sprintf('workflow.%s.entered', $this->name));
398398

399-
if ($transition) {
400-
foreach ($transition->getTos() as $place) {
401-
$this->dispatcher->dispatch($event, sprintf('workflow.%s.entered.%s', $this->name, $place));
402-
}
403-
} elseif (!empty($this->definition->getInitialPlaces())) {
404-
foreach ($this->definition->getInitialPlaces() as $place) {
405-
$this->dispatcher->dispatch($event, sprintf('workflow.%s.entered.%s', $this->name, $place));
406-
}
399+
foreach ($marking->getPlaces() as $placeName => $nbToken) {
400+
$this->dispatcher->dispatch($event, sprintf('workflow.%s.entered.%s', $this->name, $placeName));
407401
}
408402
}
409403

0 commit comments

Comments
 (0)
0