Skip to content

Commit d669eb3

Browse files
authored
deprecate TaggedIterator and TaggedLocator attributes
1 parent bd1af26 commit d669eb3

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

reference/attributes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ Dependency Injection
4444
* :ref:`Target <autowiring-multiple-implementations-same-type>`
4545
* :ref:`When <service-container_limiting-to-env>`
4646

47+
.. deprecated:: 7.1
48+
49+
The
50+
:class:`Symfony\\Component\\DependencyInjection\\Attribute\\TaggedIterator`
51+
and
52+
:class:`Symfony\\Component\\DependencyInjection\\Attribute\\TaggedLocator`
53+
were deprecated in Symfony 7.1.
54+
4755
EventDispatcher
4856
~~~~~~~~~~~~~~~
4957

service_container/service_subscribers_locators.rst

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

310+
.. deprecated:: 7.1
311+
312+
The
313+
:class:`Symfony\\Component\\DependencyInjection\\Attribute\\TaggedIterator`
314+
and
315+
:class:`Symfony\\Component\\DependencyInjection\\Attribute\\TaggedLocator`
316+
were deprecated in Symfony 7.1.
317+
:class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireIterator`
318+
and
319+
:class:`Symfony\\Component\\DependencyInjection\\Attribute\\AutowireLocator`
320+
should be used instead.
321+
310322
.. note::
311323

312324
The above example requires using ``3.2`` version or newer of ``symfony/service-contracts``.
@@ -432,13 +444,13 @@ or directly via PHP attributes:
432444
namespace App;
433445
434446
use Psr\Container\ContainerInterface;
435-
use Symfony\Component\DependencyInjection\Attribute\TaggedLocator;
447+
use Symfony\Component\DependencyInjection\Attribute\AutowireLocator;
436448
437449
class CommandBus
438450
{
439451
public function __construct(
440452
// creates a service locator with all the services tagged with 'app.handler'
441-
#[TaggedLocator('app.handler')]
453+
#[AutowireLocator('app.handler')]
442454
private ContainerInterface $locator,
443455
) {
444456
}
@@ -674,12 +686,12 @@ to index the services:
674686
namespace App;
675687
676688
use Psr\Container\ContainerInterface;
677-
use Symfony\Component\DependencyInjection\Attribute\TaggedLocator;
689+
use Symfony\Component\DependencyInjection\Attribute\AutowireLocator;
678690
679691
class CommandBus
680692
{
681693
public function __construct(
682-
#[TaggedLocator('app.handler', indexAttribute: 'key')]
694+
#[AutowireLocator('app.handler', indexAttribute: 'key')]
683695
private ContainerInterface $locator,
684696
) {
685697
}
@@ -789,12 +801,12 @@ get the value used to index the services:
789801
namespace App;
790802
791803
use Psr\Container\ContainerInterface;
792-
use Symfony\Component\DependencyInjection\Attribute\TaggedLocator;
804+
use Symfony\Component\DependencyInjection\Attribute\AutowireLocator;
793805
794806
class CommandBus
795807
{
796808
public function __construct(
797-
#[TaggedLocator('app.handler', 'defaultIndexMethod: 'getLocatorKey')]
809+
#[AutowireLocator('app.handler', 'defaultIndexMethod: 'getLocatorKey')]
798810
private ContainerInterface $locator,
799811
) {
800812
}

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)