Skip to content

[DependencyInjection] Priority ignored for tagged locator #42506

@BoShurik

Description

@BoShurik

Symfony version(s) affected: 5.3.6

Description
Currently it's allowed to configure priority on !tagged_locator but it's ignored while dumping container.

How to reproduce

App\Handler\HandlerLocator:
    arguments:
        $locator: !tagged_locator
            tag: app.handler
            index_by: 'id'
            default_index_method: 'getId'
            default_priority_method: 'getPriority'
class HandlerLocator
{
    public function __construct(private ServiceLocator $locator)
    {
    }

    public function get(string $id): HandlerInterface
    {
        return $this->locator->get($id);
    }

    public function available(): array
    {
        return array_keys($this->locator->getProvidedServices());
    }
}
// Outputs with wrong order
foreach ($this->locator->available() as $id) {
    $output->writeln($id);
}

Additional context
Priority does not make much sense in locator but I have a form type which contains all handlers and I want to output them according to priority

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