I have been following tutorials, and all instructions show it\'s done the exact same way, but it doesn\'t seem to work in Symfony 4. Is there something I\'m overlooking or i
In my case I use AbstractController and as malcolm says, it is beter to inject the service directrly in your action, even so, I call a method several times and I think that overwrite getSubscribedServices is clener for my porpuse.
public static function getSubscribedServices(): array
{
$services = parent::getSubscribedServices();
$services['fos_elastica.manager'] = RepositoryManagerInterface::class;
$services['knp_paginator'] = PaginatorInterface::class;
return $services;
}
private function listHandler(Search $search, Request $request, int $page): Response
{
//...
$repository = $this->container->get('fos_elastica.manager')->getRepository(Foo::class);
//...
}