Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #26092 [Workflow] Add a MetadataStore to fetch some metadata …
…(lyrixx) This PR was merged into the 4.1-dev branch. Discussion ---------- [Workflow] Add a MetadataStore to fetch some metadata | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | yes (little) | Deprecations? | yes | Tests pass? | yes | Fixed tickets | #23257 | License | MIT | Doc PR | TODO --- This is an attempt to fix #23257. I first started to implement `Ẁorkflow::getMetadata()`, `Transition::getMetadata()` and `Place::getMetadata()`. **BUT**, there are no `Place` class. For now it's just a `string`. So dealing with BC is a nightmare. So I tried to find another way to fix the issue. [This comment](#23257 (comment)) summary well the two options. But this PR is (will be) a mix of theses 2 options. First it will be possible to configure the workflow/metadata like this: ```yaml blog_publishing: supports: - AppBundle\Entity\BlogPost metada: label: Blog publishing description: Manages blog publishing places: draft: metadata: description: Blog has just been created color: grey review: metadata: description: Blog is waiting for review color: blue transitions: to_review: from: draft to: review metadata: label: Submit for review route: admin.blog.review ``` I think is very good for the DX. Simple to understand. All metadata will live in a `MetadataStoreInterface`. If metadata are set via the configuration (workflows.yaml), then we will use the `InMemoryMetadataStore`. Having a MetadataStoreInterface allow user to get dynamic value for a place / transitions. It's really flexible. (But is it a valid use case ?) Then, to retrieve these data, the end user will have to write this code: ```php public function onReview(Event $event) { $metadataStore = $event->getWorkflow()->getMetadataStore(); foreach ($event->getTransition()->getTos() as $place) { $this->flashbag->add('info', $metadataStore->getPlaceMetadata($place)->get('description')); } } ``` Note: I might add some shortcut to the Event class or in twig: ```jinja {% for transition in workflow_transitions(post) %} <a href="{{ workflow_metadata_transition(post, route) }}"> {{ workflow_metadata_transition(post, transition) }} </a> {% endfor %} ``` --- WDYT ? Should I continue this way, or should I introduce a `Place` class (there will be so many deprecation ...) Commits ------- bd1f2c8 [Workflow] Add a MetadataStore
- Loading branch information
Showing
26 changed files
with
569 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
CHANGELOG | ||
========= | ||
|
||
4.1.0 | ||
----- | ||
|
||
* add a `workflow_metadata` function | ||
|
||
3.4.0 | ||
----- | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.