Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting service to child controller

Tags:

php

symfony

I have two bundle A and B. A is the parent of B. Bundle 'A' has AController with construct method with 3 arguments which is defined as a service.

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

Is there anything i missed out on.

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

service for Acontroller

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

For bundle B

Class BController extends Acontroller{
    .....
}

service for Bcontroller

controller_B:
    class: B\Bundle\BBundle\Controller\BController
    arguments:
        - @B
        - "%B.config%"
        - @form.factory
like image 299
Bijesh Shrestha Avatar asked Sep 29 '22 03:09

Bijesh Shrestha


1 Answers

This looks like a routing problem. Did you set 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

like image 64
Gnucki Avatar answered Oct 18 '22 15:10

Gnucki