Skip to content

[DI] Allow class-defined priority when using _instanceof + tags #32976

@gitomato

Description

@gitomato

Description
Let's use a sample similar to the doc:

services:
  _instanceof:
    App\Handler:
      tags:
        - { name: 'app.handler', priority: 20 }

  App\HandlerCollection:
    arguments: [!tagged app.handler]

All instances of App\Handler will have the same priority.

I would like to define a different priority for each handler.

Example
This might not be the cleanest solution but you get the point.

services:
  _instanceof:
    App\Handler:
      tags:
        - { name: 'app.handler', priority: 'getPriority' }
namespace App;

class MyHandler implements Handler {
  public static function getPriority(): int {
    return 10;
  }
}

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