这是我的第一个问题,我在RegisterListenersPass.php第101行有这个错误ReflectionException:Class Acme \ exampleBundle \ Handler \ AuthenticationHandler.php不存在。我使用FOSUserBundle和Symfony的2ReflectionException在RegisterListenersPass.php第101行:类不存在Symfony 2
services.xml中
<service id="login_listener" class="%vixur.login_listener.class%">
<tag name="kernel.event_subscriber"/>
</service>
AuthenticationHandler.php:
<?php
namespace acme\exampleBundle\Handler;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\FormEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
* Listener responsible to change the redirection at the end of the password resetting
*/
class AuthenticationHandler implements EventSubscriberInterface
{
private $container;
public function __construct()
{
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return array(
FOSUserEvents::SECURITY_IMPLICIT_LOGIN => 'onSecurityImplicitLogin',
);
}
public function onSecurityImplicitLogin(FormEvent $event)
{
$url = $this->router->generate('ex_homepage');
$event->setResponse(new RedirectResponse($url));
}
}
谢谢!
'Acme的!== acme'。你的命名空间是不同的,它正在寻找'Acme \ exampleBundle',但你的实际命名空间是'acme \ exampleBundle'。 – qooplmao