@@ -248,12 +248,9 @@ machine type, use ``camelCased workflow name + StateMachine``::
248248
249249 class MyClass
250250 {
251- private $blogPublishingWorkflow;
252-
253251 // Symfony will inject the 'blog_publishing' workflow configured before
254- public function __construct(WorkflowInterface $blogPublishingWorkflow)
252+ public function __construct(private readonly WorkflowInterface $blogPublishingWorkflow)
255253 {
256- $this->blogPublishingWorkflow = $blogPublishingWorkflow;
257254 }
258255
259256 public function toReview(BlogPost $post)
@@ -268,10 +265,38 @@ machine type, use ``camelCased workflow name + StateMachine``::
268265 }
269266 }
270267
268+ Workflows can also be injected thanks to their name and the
269+ :class: `Symfony\\ Component\\ DependencyInjection\\ Attribute\\ Target `
270+ attribute::
271+
272+ use App\Entity\BlogPost;
273+ use Symfony\Component\DependencyInjection\Attribute\Target;
274+ use Symfony\Component\Workflow\WorkflowInterface;
275+
276+ class MyClass
277+ {
278+ public function __construct(
279+ #[Target('blog_publishing')]
280+ private readonly WorkflowInterface $workflow
281+ ) {
282+ }
283+
284+ // ...
285+ }
286+
287+ This allows you to decorrelate the argument name of any implementation
288+ name.
289+
271290.. versionadded :: 6.2
272291
273292 All workflows and state machines services are tagged since in Symfony 6.2.
274293
294+ .. versionadded :: 6.3
295+
296+ Injecting a workflow with only its name and
297+ :class: `Symfony\\ Component\\ DependencyInjection\\ Attribute\\ Target ` was
298+ introduced in Symfony 6.3.
299+
275300.. tip ::
276301
277302 If you want to retrieve all workflows, for documentation purposes for example,
0 commit comments