-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Workflow] Mention the workflow.marking_store.service
option
#19129
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
[Workflow] Mention the workflow.marking_store.service
option
#19129
Conversation
885aba2
to
e2a0b7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice ! Thanks for taking care of this one.
I have a little comment about the Marking store implementation...
workflow.rst
Outdated
/** | ||
* @var string | ||
*/ | ||
private $property; | ||
|
||
public function __construct(string $property = 'property') | ||
{ | ||
$this->property = $property; | ||
} | ||
|
||
public function getMarking(object $subject): Marking | ||
{ | ||
$r = new \ReflectionObject($subject); | ||
$property = $r->getProperty($this->property); | ||
|
||
return new Marking([$property->getValue($subject) => 1]); | ||
} | ||
|
||
public function setMarking(object $subject, Marking $marking): void | ||
{ | ||
$r = new \ReflectionObject($subject); | ||
$property = $r->getProperty($this->property); | ||
|
||
$property->setValue($subject, $marking); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simplify this a lot
- Don't use the reflection
- hardcode the property
- typehint with this real object
Since this is an example, we don't need to abstract things
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! That's updated 🙂
e2a0b7f
to
ceaf2c8
Compare
workflow.rst
Outdated
use Symfony\Component\Workflow\Marking; | ||
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface; | ||
|
||
class BlogPostMarkingStore implements MarkingStoreInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class BlogPostMarkingStore implements MarkingStoreInterface | |
final class BlogPostMarkingStore implements MarkingStoreInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you go 🙂
ceaf2c8
to
175807f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 thanks a lot
Thank you Alexandre. |
I just discovered this option when trying to implement an enum marking store and make it work. The
service
option is indeed referenced here: https://symfony.com/doc/current/reference/configuration/framework.html#marking-store but it isn't explained how to use it. I propose to add this section which could help a lotFriendly ping @lyrixx if you'd like to check 🙂