Answer the question
In order to leave comments, you need to log in
How to override the controller?
I'm trying to change the user registration order to add roles to them automatically.
Unable to override controller.
<?php
namespace ACVote\UsersBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class ACVoteUsersBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
<?php
namespace ACVote\UsersBundle\Controller;
use FOS\UserBundle\Controller\RegistrationController as BaseController;
use Symfony\Component\HttpFoundation\Request;
class RegistrationController extends BaseController
{
public function registerAction(Request $request)
{
/** @var $formFactory \FOS\UserBundle\Form\Factory\FactoryInterface */
$formFactory = $this->get('fos_user.registration.form.factory');
/** @var $userManager \FOS\UserBundle\Model\UserManagerInterface */
$userManager = $this->get('fos_user.user_manager');
/** @var $dispatcher \Symfony\Component\EventDispatcher\EventDispatcherInterface */
$dispatcher = $this->get('event_dispatcher');
$user = $userManager->createUser();
$user->setEnabled(true);
$user->setSuperAdmin(true)
$user->SetRole(ROLE_SUPER_ADMIN);
$event = new GetResponseUserEvent($user, $request);
/*--------*/
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question