merged branch fabpot/subscribers (PR #5919)
This PR was merged into the master branch. Commits -------af87c2b
changed the Firewall to be a proper subscriber02bd359
changed the remember-me listener to be a proper subscriber Discussion ---------- Changed some security classes to implement the EventSubscriberInterface interface --------------------------------------------------------------------------- by fabpot at 2012-11-06T10:11:28Z That could also be done in 2.1. What do you think?
This commit is contained in:
commit
4f1547a811
@ -106,7 +106,7 @@
|
||||
|
||||
<!-- Firewall related services -->
|
||||
<service id="security.firewall" class="%security.firewall.class%">
|
||||
<tag name="kernel.event_listener" event="kernel.request" method="onKernelRequest" priority="8" />
|
||||
<tag name="kernel.event_subscriber" />
|
||||
<argument type="service" id="security.firewall.map" />
|
||||
<argument type="service" id="event_dispatcher" />
|
||||
</service>
|
||||
|
@ -60,7 +60,7 @@
|
||||
</service>
|
||||
|
||||
<service id="security.rememberme.response_listener" class="%security.rememberme.response_listener.class%">
|
||||
<tag name="kernel.event_listener" event="kernel.response" method="onKernelResponse" />
|
||||
<tag name="kernel.event_subscriber" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
|
@ -12,8 +12,10 @@
|
||||
namespace Symfony\Component\Security\Http;
|
||||
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* Firewall uses a FirewallMap to register security listeners for the given
|
||||
@ -25,7 +27,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class Firewall
|
||||
class Firewall implements EventSubscriberInterface
|
||||
{
|
||||
private $map;
|
||||
private $dispatcher;
|
||||
@ -68,4 +70,9 @@ class Firewall
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(KernelEvents::REQUEST => array('onKernelRequest', 8));
|
||||
}
|
||||
}
|
||||
|
@ -12,13 +12,15 @@
|
||||
namespace Symfony\Component\Security\Http\RememberMe;
|
||||
|
||||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
/**
|
||||
* Adds remember-me cookies to the Response.
|
||||
*
|
||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||
*/
|
||||
class ResponseListener
|
||||
class ResponseListener implements EventSubscriberInterface
|
||||
{
|
||||
public function onKernelResponse(FilterResponseEvent $event)
|
||||
{
|
||||
@ -29,4 +31,9 @@ class ResponseListener
|
||||
$response->headers->setCookie($request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents()
|
||||
{
|
||||
return array(KernelEvents::RESPONSE => 'onKernelResponse');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user