Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot override FOS\UserBundle\Controller\RegistrationController #48

Open
ragulan77 opened this issue Jan 9, 2014 · 2 comments
Open

Comments

@ragulan77
Copy link

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,

@leopro
Copy link
Member

leopro commented Jan 29, 2014

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

@zisato
Copy link

zisato commented Mar 29, 2014

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants