Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DependencyInjection] Make #[AsTaggedItem] repeatable #20522

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions service_container/tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1281,4 +1281,24 @@ be used directly on the class of the service you want to configure::
// ...
}

The attribute can be repeated on the same class to define multiple tags
with different indexes and priorities::

// src/Handler/One.php
namespace App\Handler;

use Symfony\Component\DependencyInjection\Attribute\AsTaggedItem;

#[AsTaggedItem(index: 'handler_one', priority: 10)]
#[AsTaggedItem(index: 'handler_two', priority: 20)]
class One
{
// ...
}

.. versionadded:: 7.3

The support for repeated ``#[AsTaggedItem]`` attributes was introduced in
Symfony 7.3.

.. _`PHP constructor promotion`: https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion
Loading