docs icon indicating copy to clipboard operation
docs copied to clipboard

Autowire attribute

Open PaulCombal opened this issue 1 year ago • 0 comments

I didn't do too much digging, but this did't work in Symfony 7:

    public function __construct(
        #[Autowire('api_platform.doctrine.orm.state.item_provider')]
        private ProviderInterface $itemProvider,
    )

what worked:

    public function __construct(
        #[Autowire(service: CollectionProvider::class)] private readonly CollectionProvider $collectionProvider
    )

Documentation page: https://api-platform.com/docs/core/state-providers/

I had the following error with the docs code: "MyProvider::__construct(): Argument #1 ($collectionProvider) must be of type ApiPlatform\\State\\ProviderInterface, string given, called in .."

PaulCombal avatar Mar 19 '24 16:03 PaulCombal