Change record status: 
Project: 
Introduced in branch: 
10.3.x
Introduced in version: 
10.3.0
Description: 

Previously, to inject a collection of tagged services into another service you would use the service_collector (or service_id_collector) tags:

  module_installer:
    class: Drupal\Core\Extension\ModuleInstaller
    tags:
      - { name: service_collector, tag: 'module_install.uninstall_validator', call: addUninstallValidator }

This calls the specified method and passes each tagged service in turn for you to store inside your service.

Since that feature was added to Drupal, Symfony has added something similar but more advanced in the form of !tagged_iterator:

  module_installer:
    class: Drupal\Core\Extension\ModuleInstaller
    arguments: [!tagged_iterator module_install.uninstall_validator]

This passes a Traversable object that returns each tagged service to your service's constructor. Additionally, the services are lazily instantiated; this means that the services are not initialized until the time that you actually need to use them, unlike with the Drupal method, which is more performant.

See https://symfony.com/doc/current/service_container/tags.html#reference-ta... for the Symfony documentation on this feature.

Impacts: 
Module developers