Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Have a common way to collect services and inject it into a single one #12269

Closed
@dawehner

Description

@dawehner

Similar issue to (in the sense of having a similar context) than #11460

In Drupal we have a lot of tagged services which are injected into a single one. When we started most of them had custom Compiler Passed, but than we realized that we can easily extract that into a common service:

This would be the "collector" service:

  breadcrumb:
    class: Drupal\Core\Breadcrumb\BreadcrumbManager
    arguments: ['@module_handler']
    tags:
      - { name: service_collector, tag: breadcrumb_builder, call: addBuilder }

and then you do something like that in the client service:

  forum.breadcrumb.listing:
    class: Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder
    arguments: ['@entity.manager', '@config.factory', '@forum_manager']
    tags:
      - { name: breadcrumb_builder, priority: 314 }

Any oppinions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions