我想覆盖一个名为confirmAction 的FOS 用户操作。下面是我的动作↓</p>
/**
* Receive the confirmation token from user email provider, login the user.
*
* @param Request $request
* @param string $token
*
* @return Response
*/
public function confirmAction(Request $request, $token)
{
$utilisateur = $this->getDoctrine()
->getRepository(Utilisateur::class)
->findOneByConfirmationToken($token);
$utilisateur->setMyAttribute(null);
$em = $this->getDoctrine()->getManager();
$em->persist($utilisateur);
$em->flush();
return parent::confirmAction($request, $token);}
如果我不覆盖构造函数,我会收到错误消息,说变量没有像 $userManager、$eventDispatcher 那样声明...
Type error: Argument 1 passed to FOS\UserBundle\Controller\RegistrationController::__construct() must implement interface Symfony\Component\EventDispatcher\EventDispatcherInterface, none given, called in /var/www/html/linguanomad/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php on line 195
如果我将构造函数重写为: public function __construct(){}
我收到错误消息:在 null 上调用成员函数 findUserByConfirmationToken()
我应该重写构造函数吗?我该怎么做?