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

Skip to content

[Workflow] Remove unnecessary method calls #21784

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 4 commits into from
Closed
Changes from all commits
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
10 changes: 5 additions & 5 deletions src/Symfony/Component/Workflow/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function getMarking($subject)
throw new LogicException(sprintf('The Marking is empty and there is no initial place for workflow "%s".', $this->name));
}
$marking->mark($this->definition->getInitialPlace());

// update the subject with the new marking
$this->markingStore->setMarking($subject, $marking);
}

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

// Because the marking could have been initialized, we update the subject
$this->markingStore->setMarking($subject, $marking);

return $marking;
}

Expand All @@ -92,7 +92,7 @@ public function getMarking($subject)
*/
public function can($subject, $transitionName)
{
$transitions = $this->getEnabledTransitions($subject, $this->getMarking($subject));
$transitions = $this->getEnabledTransitions($subject);

foreach ($transitions as $transition) {
if ($transitionName === $transition->getName()) {
Expand All @@ -116,7 +116,7 @@ public function can($subject, $transitionName)
*/
public function apply($subject, $transitionName)
{
$transitions = $this->getEnabledTransitions($subject, $this->getMarking($subject));
$transitions = $this->getEnabledTransitions($subject);

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