Skip to content

[dependency-injection] Show how to get $myService #17397

Closed
@tacman

Description

@tacman

from https://symfony.com/doc/current/service_container/service_subscribers_locators.html#using-service-locators-in-compiler-passes

public function process(ContainerBuilder $container): void
{
    // ...

    $locateableServices = [
        // ...
        'logger' => new Reference('logger'),
    ];

    $myService->addArgument(ServiceLocatorTagPass::register($container, $locateableServices));
}

Could you please update the documentation to show how to get $myService?

I tried

$container->get(MyService::class)

but that's not right. Thanks.

@weaverryan or anyone else, if you answer here, I'll add it and make a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions