FOSUserBundle - 覆盖控制器

FOSUserBundle - Overriding Controller

我在尝试覆盖 FOSUserBundle 的 ResettingController 时遇到了一些(令人沮丧的)问题。

我已严格遵守文档*。我对覆盖控制器或事件订阅 onResettingPasswordSucess 感到不高兴...

这是我的控制器:

命名空间AppBundle\Controller\Frontend;

use FOS\UserBundle\Model\UserInterface;
use FOS\UserBundle\Controller\ResettingController as BaseResettingController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RedirectResponse;

class ResettingController extends BaseResettingController
{
    /**
     * {@inheritDoc}
     */
    public function requestAction()
    {
        return $this->render('FOSUserBundle:Resetting:request.html.twig');
    }

    /**
     * {@inheritDoc}
     */
    public function sendEmailAction(Request $request)
    {
        $username = $request->request->get('username');

        /** @var $user UserInterface */
        $user = $this->get('fos_user.user_manager')->findUserByUsernameOrEmail($username);

        if (null === $user) {
            return $this->render('FOSUserBundle:Resetting:request.html.twig', array(
                'invalid_username' => $username
            ));
        }

        if ($user->isPasswordRequestNonExpired($this->container->getParameter('fos_user.resetting.token_ttl'))) {
            return $this->render('FOSUserBundle:Resetting:passwordAlreadyRequested.html.twig');
        }

        if (null === $user->getConfirmationToken()) {
            /** @var $tokenGenerator \FOS\UserBundle\Util\TokenGeneratorInterface */
            $tokenGenerator = $this->get('fos_user.util.token_generator');
            $user->setConfirmationToken($tokenGenerator->generateToken());
        }

        $this->get('fos_user.mailer')->sendResettingEmailMessage($user);
        $user->setPasswordRequestedAt(new \DateTime());
        $this->get('fos_user.user_manager')->updateUser($user);

        return new RedirectResponse($this->generateUrl('fos_user_security_login',
            array('email' => $this->getObfuscatedEmail($user))
        ));
    }
}

我的 AppBundle 有这个:

<?php

namespace AppBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AppBundle extends Bundle
{
    /**
     * {@inheritDoc}
     */
    public function getParent()
    {
        return 'FOSUserBundle';
    }
}

连 PhpStorm 都告诉我...

然而父方法总是被调用?

我想要的只是当用户提交密码重置表单时,它会将他们重定向到带有闪现消息的登录页面。

你能发现什么吗?

最诚挚的问候 内森

All I want is when user submits the password reset form it redirects them to the login page with a flash message

使用事件,这是适合您的问题。 Hooking into the controllers

你有没有忘记刷新缓存?

PS : 你用的是什么配色方案?很不错