Skip to content

Commit 8b20cc8

Browse files
committed
minor #20896 Add documentation to use AsTaggedItem for value resolver priority/name (BackEndTea)
This PR was squashed before being merged into the 6.4 branch. Discussion ---------- Add documentation to use `AsTaggedItem` for value resolver priority/name This also fixes file names to match the class name Commits ------- a2e2539 Add documentation to use `AsTaggedItem` for value resolver priority/name
2 parents 558c80f + a2e2539 commit 8b20cc8

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

controller/value_resolver.rst

+16-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ this argument) or an array with the resolved value(s). Usually arguments are
322322
resolved as a single value, but variadic arguments require resolving multiple
323323
values. That's why you must always return an array, even for single values::
324324

325-
// src/ValueResolver/IdentifierValueResolver.php
325+
// src/ValueResolver/BookingIdValueResolver.php
326326
namespace App\ValueResolver;
327327

328328
use App\IdentifierInterface;
@@ -374,6 +374,20 @@ but you can set it yourself to change its ``priority`` or ``name`` attributes.
374374

375375
.. configuration-block::
376376

377+
.. code-block:: php-attributes
378+
379+
// src/ValueResolver/BookingIdValueResolver.php
380+
namespace App\ValueResolver;
381+
382+
use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem;
383+
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
384+
385+
#[AsTaggedItem(name: 'booking_id', priority: 150)]
386+
class BookingIdValueResolver implements ValueResolverInterface
387+
{
388+
// ...
389+
}
390+
377391
.. code-block:: yaml
378392
379393
# config/services.yaml
@@ -455,7 +469,7 @@ As an alternative, you can add the
455469
:class:`Symfony\\Component\\HttpKernel\\Attribute\\AsTargetedValueResolver` attribute
456470
to your resolver and pass your custom name as its first argument::
457471

458-
// src/ValueResolver/IdentifierValueResolver.php
472+
// src/ValueResolver/BookingIdValueResolver.php
459473
namespace App\ValueResolver;
460474

461475
use Symfony\Component\HttpKernel\Attribute\AsTargetedValueResolver;

0 commit comments

Comments
 (0)