i installed PUGXMultiUserBundle using this documentation and i follow this, but i have an error
Type error: Argument 1 passed to FOS\UserBundle\Controller\RegistrationController::__construct() must implement interface Symfony\Component\EventDispatcher\EventDispatcherInterface, none given...
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
service:
user_manager: pugx_user_manager
from_email:
address: "%mailer_user%"
sender_name: "%mailer_user%"
pugx_multi_user:
users:
simple_user:
entity:
class: AppBundle\Entity\SimpleUser
registration:
form:
type: AppBundle\Form\SimpleUserType
name: fos_user_registration_form
validation_groups: [Registration, Default]
template: AppBundle:Registration:simple_user.form.html.twig
society_user:
entity:
class: AppBundle\Entity\SocietyUser
registration:
form:
type: AppBundle\Form\SocietyUserType
name: fos_user_registration_form
validation_groups: [Registration, Default]
template: AppBundle:Registration:society_user.form.html.twig
and this is my RegistrationSimpleUserController:
/**
* Class RegistrationSimpleUserController
* @package AppBundle\Controller
*
*/
class RegistrationSimpleUserController extends Controller
{
/**
* @return mixed
*
*
* @Route("/register/simple", name="registration_simple_user")
*/
public function registerAction()
{
return $this->container
->get('pugx_multi_user.registration_manager')
->register('Acme\UserBundle\Entity\UserOne');
}
}
I think this is a bug in the PUGX bundle which is not up to date.
They define the FOSUserBundle Registration controller as a service like this:
pugx_multi_user.registration_controller:
class: FOS\UserBundle\Controller\RegistrationController
But the RegistrationController in the FOSUserBundle has some dependencies:
public function __construct(EventDispatcherInterface $eventDispatcher, FactoryInterface $formFactory, UserManagerInterface $userManager, TokenStorageInterface $tokenStorage)
{
$this->eventDispatcher = $eventDispatcher;
$this->formFactory = $formFactory;
$this->userManager = $userManager;
$this->tokenStorage = $tokenStorage;
}
I think you can solve it by defining an alias like this:
pugx_multi_user.registration_controller:
alias: fos_user.registration.controller
Or overriding the whole definition in your own services.yml:
pugx_multi_user.registration_controller:
class: FOS\UserBundle\Controller\RegistrationController
arguments:
- '@event_dispatcher'
- '@fos_user.registration.form.factory'
- '@fos_user.user_manager'
- '@security.token_storage'