Question

there, I am trying to override the ProfileController of FOSUSerBundle and I got an error trying to render the template, this is the code:

namespace XxX\MyBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class MyBundle extends Bundle
{
    public function getParent() 
    {
        return 'FOSUserBundle';
    }
}

Then, I try to override the controller:

<?php

namespace XxX\MyBundle\Controller;

use FOS\UserBundle\Controller\RegistrationController as BaseController;

class ProfileController extends BaseController
{
    public function myAction()
    {
        $userManager = $this->container->get('fos_user.user_manager');
        $user = $userManager->findUserByUsername($this->container->get('security.context')
                    ->getToken()
                    ->getUser());

        return $this->render('MyBundle:Profile:show.html.twig');
    }

}

I get this error:

Error: Call to undefined method XxX\MyBundle\Controller\ProfileController::render() in D:\xampp\htdocs\projects\alopatria\src\Jaguar\AloBundle\Controller\ProfileController.php line 16

I have tried:

return $this->container->get('templating')->renderResponse('MyBundle:Profile:show.html.twig');

But still failing...

Any help please?

Thanks!

Was it helpful?

Solution

The FOSUserBundle-RegistrationController doesn't extend SF2's Symfony\Bundle\FrameworkBundle\Controller\Controller which provides the render() method. It just implements ContainerAware interface.

Which error do you get when calling $this->container->get('templating')->renderResponse()?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top