Skip to content

Commit 46af1c0

Browse files
committed
Merge branch '7.1' into 7.2
* 7.1: deprecate TaggedIterator and TaggedLocator attributes
2 parents 726f843 + d85d5ee commit 46af1c0

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

reference/attributes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Dependency Injection
4545
* :ref:`When <service-container_limiting-to-env>`
4646
* :ref:`WhenNot <service-container_limiting-to-env>`
4747

48+
.. deprecated:: 7.1
49+
50+
The :class:`Symfony\\Component\\DependencyInjection\\Attribute\\TaggedIterator`
51+
and :class:`Symfony\\Component\\DependencyInjection\\Attribute\\TaggedLocator`
52+
attributes were deprecated in Symfony 7.1.
53+
4854
EventDispatcher
4955
~~~~~~~~~~~~~~~
5056

service_container/service_subscribers_locators.rst

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,14 @@ This is done by having ``getSubscribedServices()`` return an array of
307307
];
308308
}
309309

310+
.. deprecated:: 7.1
311+
312+
The :class:`Symfony\\Component\\DependencyInjection\\Attribute\\TaggedIterator`
313+
and :class:`Symfony\\Component\\DependencyInjection\\Attribute\\TaggedLocator`
314+
attributes were deprecated in Symfony 7.1 in favor of
315+
:class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireIterator`
316+
and :class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireLocator`.
317+
310318
.. note::
311319

312320
The above example requires using ``3.2`` version or newer of ``symfony/service-contracts``.
@@ -432,13 +440,13 @@ or directly via PHP attributes:
432440
namespace App;
433441
434442
use Psr\Container\ContainerInterface;
435-
use Symfony\Component\DependencyInjection\Attribute\TaggedLocator;
443+
use Symfony\Component\DependencyInjection\Attribute\AutowireLocator;
436444
437445
class CommandBus
438446
{
439447
public function __construct(
440448
// creates a service locator with all the services tagged with 'app.handler'
441-
#[TaggedLocator('app.handler')]
449+
#[AutowireLocator('app.handler')]
442450
private ContainerInterface $locator,
443451
) {
444452
}
@@ -674,12 +682,12 @@ to index the services:
674682
namespace App;
675683
676684
use Psr\Container\ContainerInterface;
677-
use Symfony\Component\DependencyInjection\Attribute\TaggedLocator;
685+
use Symfony\Component\DependencyInjection\Attribute\AutowireLocator;
678686
679687
class CommandBus
680688
{
681689
public function __construct(
682-
#[TaggedLocator('app.handler', indexAttribute: 'key')]
690+
#[AutowireLocator('app.handler', indexAttribute: 'key')]
683691
private ContainerInterface $locator,
684692
) {
685693
}
@@ -789,12 +797,12 @@ get the value used to index the services:
789797
namespace App;
790798
791799
use Psr\Container\ContainerInterface;
792-
use Symfony\Component\DependencyInjection\Attribute\TaggedLocator;
800+
use Symfony\Component\DependencyInjection\Attribute\AutowireLocator;
793801
794802
class CommandBus
795803
{
796804
public function __construct(
797-
#[TaggedLocator('app.handler', 'defaultIndexMethod: 'getLocatorKey')]
805+
#[AutowireLocator('app.handler', 'defaultIndexMethod: 'getLocatorKey')]
798806
private ContainerInterface $locator,
799807
) {
800808
}

service_container/tags.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -674,13 +674,13 @@ directly via PHP attributes:
674674
// src/HandlerCollection.php
675675
namespace App;
676676
677-
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
677+
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
678678
679679
class HandlerCollection
680680
{
681681
public function __construct(
682682
// the attribute must be applied directly to the argument to autowire
683-
#[TaggedIterator('app.handler')]
683+
#[AutowireIterator('app.handler')]
684684
iterable $handlers
685685
) {
686686
}
@@ -766,12 +766,12 @@ iterator, add the ``exclude`` option:
766766
// src/HandlerCollection.php
767767
namespace App;
768768
769-
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
769+
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
770770
771771
class HandlerCollection
772772
{
773773
public function __construct(
774-
#[TaggedIterator('app.handler', exclude: ['App\Handler\Three'])]
774+
#[AutowireIterator('app.handler', exclude: ['App\Handler\Three'])]
775775
iterable $handlers
776776
) {
777777
}
@@ -849,12 +849,12 @@ disabled by setting the ``exclude_self`` option to ``false``:
849849
// src/HandlerCollection.php
850850
namespace App;
851851
852-
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
852+
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
853853
854854
class HandlerCollection
855855
{
856856
public function __construct(
857-
#[TaggedIterator('app.handler', exclude: ['App\Handler\Three'], excludeSelf: false)]
857+
#[AutowireIterator('app.handler', exclude: ['App\Handler\Three'], excludeSelf: false)]
858858
iterable $handlers
859859
) {
860860
}
@@ -999,12 +999,12 @@ you can define it in the configuration of the collecting service:
999999
// src/HandlerCollection.php
10001000
namespace App;
10011001
1002-
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
1002+
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
10031003
10041004
class HandlerCollection
10051005
{
10061006
public function __construct(
1007-
#[TaggedIterator('app.handler', defaultPriorityMethod: 'getPriority')]
1007+
#[AutowireIterator('app.handler', defaultPriorityMethod: 'getPriority')]
10081008
iterable $handlers
10091009
) {
10101010
}
@@ -1073,12 +1073,12 @@ to index the services:
10731073
// src/HandlerCollection.php
10741074
namespace App;
10751075
1076-
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
1076+
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
10771077
10781078
class HandlerCollection
10791079
{
10801080
public function __construct(
1081-
#[TaggedIterator('app.handler', indexAttribute: 'key')]
1081+
#[AutowireIterator('app.handler', indexAttribute: 'key')]
10821082
iterable $handlers
10831083
) {
10841084
}
@@ -1187,12 +1187,12 @@ get the value used to index the services:
11871187
// src/HandlerCollection.php
11881188
namespace App;
11891189
1190-
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
1190+
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
11911191
11921192
class HandlerCollection
11931193
{
11941194
public function __construct(
1195-
#[TaggedIterator('app.handler', defaultIndexMethod: 'getIndex')]
1195+
#[AutowireIterator('app.handler', defaultIndexMethod: 'getIndex')]
11961196
iterable $handlers
11971197
) {
11981198
}

0 commit comments

Comments
 (0)