PUGXMultiUserBundle icon indicating copy to clipboard operation
PUGXMultiUserBundle copied to clipboard

Cannot override FOS\UserBundle\Controller\RegistrationController

Open ragulan77 opened this issue 11 years ago • 2 comments

Hello everyone,

I need to override the default FOS\UserBundle\Controller\RegistrationController for disabling automatic connection after registration. So I created my RegistrationController in my bundle, just like how FOSUserBundle documentation recommends.

But because of the following lines in PUGX's services.yml:

pugx_multi_user.registration_controller:
      class: FOS\UserBundle\Controller\RegistrationController

my overridden RegistrationController is not taken in count. Do you know if it is possible to override PUGX's services.yml file, in order to do something like:

pugx_multi_user.registration_controller:
      class: Acme\UserBundle\Controller\RegistrationController

Regards,

ragulan77 avatar Jan 09 '14 16:01 ragulan77

use fosub events or do a PR with a new config parameter ;-)

leopro avatar Jan 29 '14 12:01 leopro

I had the same problem and solved adding a few extra lines:

in services.yml parameters: registration_controller.class: ~

services: ... pugx_multi_user.registration_controller: class: "%registration_controller.class%"

in DependencyInjection/Configuration.php ... $rootNode-> children() ->scalarNode('registration_controller') ->defaultValue('FOS\UserBundle\Controller\RegistrationController') ->end();

in DependencyInjection/PUGXMultiUserExtension.php ... if (!isset($config['registration_controller'])) { throw new \InvalidArgumentException( 'The "registration_controller" option must be set' ); }

$container->setParameter( 'registration_controller.class', $config['registration_controller'] );

after that you can add your controller class in config.yml

pugx_multi_user: ... registration_controller: Acme\UsersBundle\Controller\RegistrationController

zisato avatar Mar 29 '14 18:03 zisato