Configuring a service to a child controller

I have two bundles A and B. A is the parent of B. Bundle 'A' has an AController with a three-argument build method, which is defined as a service.

Then I have a BController in a Bundle 'B' that extends Acontroller. I need to call the methods of controller B. I also made a service for BController. But the problem is that it throws an error with missing argument 1 in __construct.

I have not missed anything.

Class AController{ public function __construct(A,B,C) { ....... } } 

for acontroller

 controller_A: class: A\Bundle\ABundle\Controller\AController arguments: - @A - "%a.config%" - @form.factory 

For bundle B

 Class BController extends Acontroller{ ..... } 

for bcontroller

 controller_B: class: B\Bundle\BBundle\Controller\BController arguments: - @B - "%B.config%" - @form.factory 
+5
source share
1 answer

This seems like a routing problem. You installed something like:

 /** * @Route(service="your_bundle.b_controller") */ class BController extends Acontroller{ 

Explanation here: http://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/routing.html#controller-as-service

+4
source

Source: https://habr.com/ru/post/1209828/


All Articles