You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature symfony#50974 [Workflow] Add support for storing the marking in a property (lyrixx)
This PR was merged into the 6.4 branch.
Discussion
----------
[Workflow] Add support for storing the marking in a property
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | fixessymfony#49778
| License | MIT
| Doc PR |
Commits
-------
5174250 [Workflow] Add support for storing the marking in a property
thrownewLogicException(sprintf('The method "%s::%s()" does not exist.', get_debug_type($subject), $method));
52
-
}
53
-
54
52
$marking = null;
55
53
try {
56
-
$marking = $subject->{$method}();
54
+
$marking = ($this->getGetter($subject))();
57
55
} catch (\Error$e) {
58
56
$unInitializedPropertyMessage = sprintf('Typed property %s::$%s must not be accessed before initialization', get_debug_type($subject), $this->property);
59
57
if ($e->getMessage() !== $unInitializedPropertyMessage) {
@@ -68,7 +66,7 @@ public function getMarking(object $subject): Marking
68
66
if ($this->singleState) {
69
67
$marking = [(string) $marking => 1];
70
68
} elseif (!\is_array($marking)) {
71
-
thrownewLogicException(sprintf('The method "%s::%s()" did not return an array and the Workflow\'s Marking store is instantiated with $singleState=false.', get_debug_type($subject), $method));
69
+
thrownewLogicException(sprintf('The marking stored in "%s::$%s" is not an array and the Workflow\'s Marking store is instantiated with $singleState=false.', get_debug_type($subject), $this->property));
72
70
}
73
71
74
72
returnnewMarking($marking);
@@ -82,12 +80,53 @@ public function setMarking(object $subject, Marking $marking, array $context = [
if (method_exists($subject, $method) && (new \ReflectionMethod($subject, $method))->isPublic()) {
111
+
return MarkingStoreMethod::METHOD;
112
+
}
113
+
114
+
try {
115
+
if ((new \ReflectionProperty($subject, $property))->isPublic()) {
116
+
return MarkingStoreMethod::PROPERTY;
117
+
}
118
+
} catch (\ReflectionException) {
89
119
}
90
120
91
-
$subject->{$method}($marking, $context);
121
+
thrownewLogicException(sprintf('Cannot store marking: class "%s" should have either a public method named "%s()" or a public property named "$%s"; none found.', get_debug_type($subject), $method, $property));
0 commit comments