Tagged services

Service definitions can also be tagged in order to inform the container as to a specific purpose that they serve. Typically, these are picked up by a collector service that uses them for a given subsystem. As an example, if we wanted to tag the hello_world.salutation service, it would look something this:

hello_world.salutation:  class: Drupal\hello_world\HelloWorldSalutation  tags:    - {name: tag_name}

Tags can also get a priority, as we will see in some examples later in this book.

Get Drupal 8 Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.