What do I have:
services.yaml
:
app.foo.bar:
class: App\Foo\Bar
arguments: #[ ... ]
Controller:
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class MyController extends Controller
{
public function baz(Request $request)
{
$this->get('some_bundle.some_service');
}
}
And it works.
But as Symfony\Bundle\FrameworkBundle\Controller\Controller
is deprecated, I've tried to extend Symfony\Bundle\FrameworkBundle\Controller\AbstractController
and I got
Service "some_bundle.some_service" not found: even though it exists in the app's container, the container inside "App\Controller\MyController" is a smaller service locator that only knows about the "doctrine", "http_kernel", "parameter_bag", "request_stack", "router", "serializer" and "session" services. Try using dependency injection instead.
Can I use get()
somehow with AbstractController
? AbstractController
uses ControllerTrait
, I wonder why the error takes place.