Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions lock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ For example, to inject the ``invoice`` package defined earlier::

When :ref:`dealing with multiple implementations of the same type <autowiring-multiple-implementations-same-type>`
the ``#[Target]`` attribute helps you select which one to inject. Symfony creates
a target called "asset package name" + ``.lock.factory`` suffix.
a target with the same name as the lock.

For example, to select the ``invoice`` lock defined earlier::

Expand All @@ -329,8 +329,13 @@ For example, to select the ``invoice`` lock defined earlier::
class SomeService
{
public function __construct(
#[Target('invoice.lock.factory')] private LockFactory $lockFactory
#[Target('invoice')] private LockFactory $lockFactory
): void {
// ...
}
}

.. versionadded:: 7.4

Before Symfony 7.4, the target name had to include the ``.lock.factory``
suffix (e.g. ``#[Target('invoice.lock.factory')]``).
9 changes: 7 additions & 2 deletions rate_limiter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ argument named ``$anonymousApiLimiter``::

When :ref:`dealing with multiple implementations of the same type <autowiring-multiple-implementations-same-type>`
the ``#[Target]`` attribute helps you select which one to inject. Symfony creates
a target called "rate limiter name" + ``.limiter`` suffix.
a target with the same name as the rate limiter.

For example, to select the ``anonymous_api`` limiter defined earlier, use
``anonymous_api.limiter`` as the target::
Expand All @@ -273,7 +273,7 @@ For example, to select the ``anonymous_api`` limiter defined earlier, use
class ApiController extends AbstractController
{
public function index(
#[Target('anonymous_api.limiter')] RateLimiterFactoryInterface $rateLimiter
#[Target('anonymous_api')] RateLimiterFactoryInterface $rateLimiter
): Response
{
// ...
Expand All @@ -286,6 +286,11 @@ For example, to select the ``anonymous_api`` limiter defined earlier, use
added and should now be used for autowiring instead of
:class:`Symfony\\Component\\RateLimiter\\RateLimiterFactory`.

.. versionadded:: 7.4

Before Symfony 7.4, the target name had to include the ``.limiter``
suffix (e.g. ``#[Target('anonymous_api.limiter')]``).

Using the Rate Limiter Service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
9 changes: 7 additions & 2 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ to inject the ``foo_package`` package defined earlier::

When :ref:`dealing with multiple implementations of the same type <autowiring-multiple-implementations-same-type>`
the ``#[Target]`` attribute helps you select which one to inject. Symfony creates
a target called "asset package name" + ``.package`` suffix.
a target with the same name as the asset package.

For example, to select the ``foo_package`` package defined earlier::

Expand All @@ -311,12 +311,17 @@ For example, to select the ``foo_package`` package defined earlier::
class SomeService
{
public function __construct(
#[Target('foo_package.package')] private PackageInterface $package
#[Target('foo_package')] private PackageInterface $package
): void {
// ...
}
}

.. versionadded:: 7.4

Before Symfony 7.4, the target name had to include the ``.package``
suffix (e.g. ``#[Target('foo_package.package')]``).

.. _reference-framework-assets-packages:

packages
Expand Down