$this->markingStore =
$markingStore ??
new MethodMarkingStore();
$this->dispatcher =
$dispatcher;
$this->name =
$name;
$this->eventsToDispatch =
$eventsToDispatch;
} public function getMarking(object
$subject, array
$context =
[]): Marking
{ $marking =
$this->markingStore->
getMarking($subject);
// check if the subject is already in the workflow
if (!
$marking->
getPlaces()) { if (!
$this->definition->
getInitialPlaces()) { throw new LogicException(sprintf('The Marking is empty and there is no initial place for workflow "%s".',
$this->name
));
} foreach ($this->definition->
getInitialPlaces() as $place) { $marking->
mark($place);
} // update the subject with the new marking
$this->markingStore->
setMarking($subject,
$marking);
if (!
$context) {