@@ -470,7 +470,8 @@ requires:
470
470
framework :
471
471
workflows :
472
472
blog_publishing :
473
- metadata : ' Blog Publishing Workflow'
473
+ metadata :
474
+ title : ' Blog Publishing Workflow'
474
475
# ...
475
476
places :
476
477
draft :
@@ -497,7 +498,7 @@ requires:
497
498
>
498
499
499
500
<framework : config >
500
- <framework : workflow name =" blog_publishing" type = " workflow " >
501
+ <framework : workflow name =" blog_publishing" >
501
502
<framework : metadata >
502
503
<framework : title >Blog Publishing Workflow</framework : title >
503
504
</framework : metadata >
@@ -563,9 +564,6 @@ In your Controller::
563
564
{
564
565
$workflow = $registry->get($article);
565
566
566
- // Or, if you don't inject the Workflow Registry, fetch from the Container:
567
- $workflow = $this->get('workflow.article');
568
-
569
567
$workflow
570
568
->getMetadataStore()
571
569
->getWorkflowMetadata()['title'] ?? false
@@ -595,8 +593,9 @@ There is a shortcut that works with everything::
595
593
In a Flash message in your Controller::
596
594
597
595
// $transition = ...; (an instance of Transition)
598
- $title = $this->get('workflow.article')->getMetadataStore()->getMetadata('title', $transition);
599
- $request->getSession()->getFlashBag()->add('info', "You have successfully applied the transition with title: '$title'");
596
+ // $workflow is a WorkFlow instance retrieved from the Registry (see above)
597
+ $title = $workflow->getMetadataStore()->getMetadata('title', $transition);
598
+ $this->addFlash('info', "You have successfully applied the transition with title: '$title'");
600
599
601
600
In a listener, access via the Event::
602
601
@@ -608,7 +607,7 @@ In a listener, access via the Event::
608
607
use Symfony\Component\Workflow\Event\GuardEvent;
609
608
use Symfony\Component\Workflow\TransitionBlocker;
610
609
611
- class DoneGuard implements EventSubscriberInterface
610
+ class OverdueGuard implements EventSubscriberInterface
612
611
{
613
612
public function guardPublish(GuardEvent $event)
614
613
{
@@ -634,7 +633,7 @@ In a listener, access via the Event::
634
633
635
634
In Twig templates, metadata is available via the ``workflow_metadata() `` function:
636
635
637
- .. code-block :: twig
636
+ .. code-block :: html+ twig
638
637
639
638
<h2>Metadata</h2>
640
639
<p>
0 commit comments