M
M
Maxim2015-09-25 22:09:52
symfony
Maxim, 2015-09-25 22:09:52

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';
    }
}

controller code. part of the code omitted.
<?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);
/*--------*/

The semicolon is intentionally omitted to show that this code is not being executed at all.
how to make it work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2015-09-25
@maxpointn2point

app/console cache:clear

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question