Skip to content

[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

Merged

Conversation

alexandre-daubois
Copy link
Member

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 lot

Friendly ping @lyrixx if you'd like to check 🙂

@carsonbot carsonbot added this to the 5.4 milestone Nov 12, 2023
@alexandre-daubois alexandre-daubois force-pushed the workflow-service-marking-store branch 2 times, most recently from 885aba2 to e2a0b7f Compare November 12, 2023 10:44
Copy link
Member

@lyrixx lyrixx left a 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
Comment on lines 832 to 842
/**
* @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);
}
}
Copy link
Member

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

Copy link
Member Author

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 🙂

@alexandre-daubois alexandre-daubois force-pushed the workflow-service-marking-store branch from e2a0b7f to ceaf2c8 Compare November 13, 2023 11:53
workflow.rst Outdated
use Symfony\Component\Workflow\Marking;
use Symfony\Component\Workflow\MarkingStore\MarkingStoreInterface;

class BlogPostMarkingStore implements MarkingStoreInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class BlogPostMarkingStore implements MarkingStoreInterface
final class BlogPostMarkingStore implements MarkingStoreInterface

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you go 🙂

@alexandre-daubois alexandre-daubois force-pushed the workflow-service-marking-store branch from ceaf2c8 to 175807f Compare November 13, 2023 13:54
Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 thanks a lot

@OskarStark
Copy link
Contributor

Thank you Alexandre.

@OskarStark OskarStark merged commit bfd678e into symfony:5.4 Nov 14, 2023
@alexandre-daubois alexandre-daubois deleted the workflow-service-marking-store branch November 14, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants