Search code examples
bundlesymfony

Symfony call a bundle in an other bundle


I'm trying to call a method of one of my bundles in my main bundle, but it returns me an error. I did something wrong for sure, but I don't know what.

The error:

Call to a member function has() on null

My code in my MainBundle, calling my ReviewBundle :

public function indexAction()
{
        $reviewController = new \ReviewBundle\Controller\DefaultController();
        $reviews = $reviewController->listAction();
        return new Response($reviews);
}

Solution

  • the listAction should already return a Response, so just return it :

    public function indexAction()
    {
            $reviewController = new \ReviewBundle\Controller\DefaultController();
            $reviews = $reviewController->listAction();
            return $reviews;
    }