I use the FOSUserBundle and I want to override his registerAction controller.
I read the documentation related to overriding controllers of FOSUserBundle but it doesn’t work. By echoing a little message in the controller, it is not print in the template.
Here is the way I chose :
I inherit my bundle from FOSUserBundle :
namespace Jheberg\MembersBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class JhebergMembersBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
And I override registerAction in the file named RegistrationController.php in the controller directory of my bundle :
namespace Jheberg\MembersBundle\Controller;
use FOS\UserBundle\Controller\RegistrationController as BaseController;
class RegistrationController extends BaseController
{
public function registerAction()
{
echo 'foo';
$response = parent::registerAction();
// do custom stuff
return $response;
}
}
Have you got any solution ?
Just spent hours trying to get this working and finally figured it out. The part I was missing was extending my User class with a User entity from within MyUserBundle. For instance:
The User entity is identical to the one in the FOSUserBundle (just with a different namespace).
If I didn’t do this, as Jeffrey mentioned, MyUserBundle wasn’t used at all (as if it didn’t exist). Now all my overridden views, controllers etc. are being used. Hope this helps.