Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bbb17df

Browse files
minor #21784 [Workflow] Remove unnecessary method calls (izzyp)
This PR was submitted for the master branch but it was merged into the 3.2 branch instead (closes #21784). Discussion ---------- [Workflow] Remove unnecessary method calls | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | License | MIT getEnabledTransitions() method only requires 1 parameter "$subject". Removed places where a second parameter "$this->getMarking($subject)" is being passed to getEnabledTransitions(). <!-- - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. - Please fill in this template according to the PR you're about to submit. - Replace this comment by a description of what your PR is solving. --> Commits ------- 12d9129 [Workflow] Remove unnecessary method calls
2 parents f11511e + 12d9129 commit bbb17df

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Symfony/Component/Workflow/Workflow.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public function getMarking($subject)
6161
throw new LogicException(sprintf('The Marking is empty and there is no initial place for workflow "%s".', $this->name));
6262
}
6363
$marking->mark($this->definition->getInitialPlace());
64+
65+
// update the subject with the new marking
66+
$this->markingStore->setMarking($subject, $marking);
6467
}
6568

6669
// check that the subject has a known place
@@ -76,9 +79,6 @@ public function getMarking($subject)
7679
}
7780
}
7881

79-
// Because the marking could have been initialized, we update the subject
80-
$this->markingStore->setMarking($subject, $marking);
81-
8282
return $marking;
8383
}
8484

@@ -92,7 +92,7 @@ public function getMarking($subject)
9292
*/
9393
public function can($subject, $transitionName)
9494
{
95-
$transitions = $this->getEnabledTransitions($subject, $this->getMarking($subject));
95+
$transitions = $this->getEnabledTransitions($subject);
9696

9797
foreach ($transitions as $transition) {
9898
if ($transitionName === $transition->getName()) {
@@ -116,7 +116,7 @@ public function can($subject, $transitionName)
116116
*/
117117
public function apply($subject, $transitionName)
118118
{
119-
$transitions = $this->getEnabledTransitions($subject, $this->getMarking($subject));
119+
$transitions = $this->getEnabledTransitions($subject);
120120

121121
// We can shortcut the getMarking method in order to boost performance,
122122
// since the "getEnabledTransitions" method already checks the Marking

0 commit comments

Comments
 (0)