Skip to content

[DIC] Factory + TaggedLocator does not work with defaultIndexMethod #57830

@lyrixx

Description

@lyrixx

Symfony version(s) affected

5.4.40

Description

Using a factory, and tagged locator does not work

services:
    App\Jerome\JeromeInterface:
        factory: ['@App\Jerome\ImplemSelector', selectImplem]
class ImplemSelector
{
    public function __construct(
        #[TaggedLocator(JeromeInterface::class, defaultIndexMethod: 'getNameStoredInDb')]
        private readonly ServiceLocator $serviceLocator
    ) {
    }

    public function selectImplem(): JeromeInterface
    {
        $name = ['first', 'second'][random_int(0, 1)];

        return $this->serviceLocator->get($name);
    }
}

How to reproduce

I made a reproducer

Possible Solution

No response

Additional Context

No response

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy