您好我试图覆盖FOSUserBundle注册控制器,以便有两种类型的用户和两种不同的形式
我有错误:
Type error: Too few arguments to function Utilisateurs\UtilisateursBundle\Controller\RegistrationController::__construct(), 0 passed in /Users/Antoine/Desktop/HC/Symfony/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php on line 195 and exactly 4 expected
这是我的控制器
namespace Utilisateurs\UtilisateursBundle\Controller;
class RegistrationController extends BaseController
{
/**
* @param Request $request
*
* @return Response
*/
public function registerAction(Request $request)
{
$user = $this->userManager->createUser();
$user->setEnabled(true);
$user->addRole("ROLE_PRO");
$event = new GetResponseUserEvent($user, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_INITIALIZE, $event);
if (null !== $event->getResponse()) {
return $event->getResponse();
}
$form = $this->formFactory->create(new ProRegistrationType());
$form->setData($user);
$form->handleRequest($request);
if ($form->isSubmitted()) {
if ($form->isValid()) {
$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_SUCCESS, $event);
$this->userManager->updateUser($user);
if (null === $response = $event->getResponse()) {
$url = $this->generateUrl('fos_user_registration_confirmed');
$response = new RedirectResponse($url);
}
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_COMPLETED, new FilterUserResponseEvent($user, $request, $response));
return $response;
}
$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_FAILURE, $event);
if (null !== $response = $event->getResponse()) {
return $response;
}
}
return $this->render('@FOSUser/Registration/register.html.twig', array(
'form' => $form->createView(),
));
}
}
我继续使用focuserbundle文档,他们只讨论在FOSuserbundle的1.3版本中覆盖控制器 谢谢你的帮助
答案 0 :(得分:0)
要覆盖FosUserBundle控制器,您应该声明FOSUserBundle的子级。我不明白为什么你有构造函数?容器中有容器,您可以拥有所需的一切。