Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Workflow] Mark registry as internal and deprecate the service#46000
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
nicolas-grekas left a comment
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.
Makes sense to me.
we should also deprecate the corresponding autowiring alias:
src/Symfony/Bundle/FrameworkBundle/Resources/config/workflow.php: ->alias(Registry::class, 'workflow.registry')
src/Symfony/Bundle/FrameworkBundle/Command/WorkflowDumpCommand.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
fabpot commentedJul 20, 2022
@lyrixx Do you have time to finish this one? |
lyrixx commentedJul 20, 2022
Yes, I'll do that ASAP, But I'm on holidays for 2 weeks. I'll do that after! |
Registry as internal and add a ServiceLocatorlyrixx commentedAug 12, 2022
Hello, I pushed a new version without the service locator. I also updated the PR description with the new usage |
Instead, all workflow services are tagged and can be injected with thefollowing YAML syntax:```yaml!tagged_locator { tag: workflow, index_by: name }```or PHP syntax:```phptagged_locator('workflow', 'name')```Also, two others tags exists for each workflow types* `workflow.workflow`* `workflow.state_machine`fabpot commentedAug 12, 2022
Thank you@lyrixx. |
This PR was merged into the 6.2 branch.Discussion----------[FrameworkBundle] clean up unused variables| Q | A| ------------- | ---| Branch? | 6.2| Bug fix? | no| New feature? | no| Deprecations? | no| Tickets || License | MIT| Doc PR |spotted while reviewing#46000Commits-------ccfb1e5 clean up unused variables
tacman commentedOct 25, 2022
I'm in the category of programmers that injected the workflow registry in order to get a list of workflows in a helper bundle for workflow. // now deprecated, following https://symfony.com/doc/current/workflow.html#accessing-the-workflow-in-a-classclass WorkflowHelperService{publicfunction __construct(privateRegistry$workflowRegistry,// in loadExtension of the bundle:$builder->autowire(WorkflowHelperService::class) ->setArgument('$workflowRegistry',new Reference('workflow.registry')); // better wayclass WorkflowHelperService{publicfunction __construct(privateServiceLocator$locator,// loadExtension()$builder->autowire(WorkflowHelperService::class) ->setArgument('$locator', tagged_locator(tag: 'workflow', indexAttribute: 'name' )) ->setAutoconfigured(true) ; Using this, I'm not getting any services in the locator, $this->locator->count() is zero. I imagine I'm not using tagger_locator correctly, or I'm doing this in the wrong spot (I'm doing this in loadExtension of my bundle, perhaps it needs to be done in the compiler pass? If so, could you point me in the right direction on how to do that, I still find the bundle interactions a bit intimidating. |
tacman commentedOct 25, 2022
Also, is this the right spot for that question? The issue itself is closed, should I open a new one? |
stof commentedOct 25, 2022
You should open a new discussion |
This is not recommended sincesymfony/symfony#46000
This PR was merged into the 6.2 branch.Discussion----------[Workflow] Do not talk about registryThis is not recommended sincesymfony/symfony#46000Commits-------e169f78 [Workflow] Do not talk about registry
Uh oh!
There was an error while loading.Please reload this page.
The Registry was added to be able to get a workflow easily from twig templates
without having to specify the workflow name.
Unfortunately, many people thought this was the only way to get a workflow and
we even add some flexibility to retrieve the workflow from the registry.
I think it's a bad idea to inject the registry, it has the same default as
injecting the Container: It's a black box, does not respect SOLID principle and
the demeter law, and make testing harder.
So I decided to mark the registry as internal. Instead people have to inject the
"right" workflow where they need it.
It can be legit to need all workflows, for documentation or for testing.
So, all workflow services are tagged and can be injected with the
following YAML syntax:
!tagged_locator { tag: workflow, index_by: name }or PHP syntax:
Also, two others tags exists for each workflow types
workflow.workflowworkflow.state_machine