Skip to content

Commit 82deb29

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: Fixed RST issues [Workflow] Fixes the examples related to metadata
2 parents 3bbc3ea + fb26f4f commit 82deb29

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

service_container/service_subscribers_locators.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -427,29 +427,29 @@ of the ``key`` tag attribute (as defined in the ``index_by`` locator option):
427427
<container xmlns="http://symfony.com/schema/dic/services"
428428
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
429429
xsi:schemaLocation="http://symfony.com/schema/dic/services
430-
http://symfony.com/schema/dic/services/services-1.0.xsd">
430+
https://symfony.com/schema/dic/services/services-1.0.xsd">
431431
432432
<services>
433433
<service id="App\Handler\One">
434-
<tag name="app.handler" key="handler_one" />
434+
<tag name="app.handler" key="handler_one"/>
435435
</service>
436436
437437
<service id="App\Handler\Two">
438-
<tag name="app.handler" key="handler_two" />
438+
<tag name="app.handler" key="handler_two"/>
439439
</service>
440440
441441
<service id="App\HandlerCollection">
442442
<!-- inject all services tagged with app.handler as first argument -->
443-
<argument type="tagged_locator" tag="app.handler" index-by="key" />
443+
<argument type="tagged_locator" tag="app.handler" index-by="key"/>
444444
</service>
445445
</services>
446446
</container>
447447
448448
.. code-block:: php
449449
450450
// config/services.php
451-
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
452451
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
452+
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
453453
454454
$container->register(App\Handler\One::class)
455455
->addTag('app.handler', ['key' => 'handler_one']);
@@ -517,14 +517,14 @@ attribute to the locator service defining the name of this custom method:
517517
<container xmlns="http://symfony.com/schema/dic/services"
518518
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
519519
xsi:schemaLocation="http://symfony.com/schema/dic/services
520-
http://symfony.com/schema/dic/services/services-1.0.xsd">
520+
https://symfony.com/schema/dic/services/services-1.0.xsd">
521521
522522
<services>
523523
524524
<!-- ... -->
525525
526526
<service id="App\HandlerCollection">
527-
<argument type="tagged_locator" tag="app.handler" default-index-method="myOwnMethodName" />
527+
<argument type="tagged_locator" tag="app.handler" default-index-method="myOwnMethodName"/>
528528
</service>
529529
</services>
530530
</container>

workflow.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -673,18 +673,28 @@ Then you can access this metadata in your controller as follows::
673673
->getWorkflowMetadata()['title'] ?? 'Default title'
674674
;
675675

676-
// or
676+
$maxNumOfWords = $workflow
677+
->getMetadataStore()
678+
->getPlaceMetadata('draft')['max_num_of_words'] ?? 500
679+
;
680+
677681
$aTransition = $workflow->getDefinition()->getTransitions()[0];
678-
$transitionTitle = $workflow
682+
$priority = $workflow
679683
->getMetadataStore()
680684
->getTransitionMetadata($aTransition)['priority'] ?? 0
681685
;
682686
}
683687

684-
There is a shortcut that works with every metadata level::
688+
There is a ``getMetadata()`` method that works with all kinds of metadata::
689+
690+
// pass no arguments to getMetadata() to get "workflow metadata"
691+
$title = $workflow->getMetadataStore()->getMetadata()['title'];
692+
693+
// pass a string (the place name) to getMetadata() to get "place metadata"
694+
$maxNumOfWords = $workflow->getMetadataStore()->getMetadata('draft')['max_num_of_words'];
685695

686-
$title = $workflow->getMetadataStore()->getMetadata('title');
687-
$priority = $workflow->getMetadataStore()->getMetadata('priority');
696+
// pass a Transition object to getMetadata() to get "transition metadata"
697+
$priority = $workflow->getMetadataStore()->getMetadata($aTransition)['priority'];
688698

689699
In a :ref:`flash message <flash-messages>` in your controller::
690700

0 commit comments

Comments
 (0)