added two interfaces: EventInterface and EventDispatcherInterface

This commit is contained in:
Fabien Potencier 2011-01-25 14:23:23 +01:00
parent b325487388
commit 0e66e388ec
31 changed files with 347 additions and 168 deletions

View File

@ -16,8 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Request\ParamConverter\ConverterManager;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventInterface;
/**
* Converts \ReflectionParameters for Controller actions into Objects if the \ReflectionParameter have a class
@ -44,14 +43,14 @@ class ParamConverterListener
}
/**
* @param Event $event
* @param mixed $controller
* @param EventInterface $event
* @param mixed $controller
*
* @return mixed
*
* @throws NotFoundHttpException
*/
public function filterController(Event $event, $controller)
public function filterController(EventInterface $event, $controller)
{
if (!is_array($controller)) {
return $controller;

View File

@ -12,8 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Debug;
use Symfony\Bundle\FrameworkBundle\EventDispatcher as BaseEventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Debug\EventDispatcherTraceableInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -45,7 +44,7 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherTrac
/**
* {@inheritDoc}
*/
public function notify(Event $event)
public function notify(EventInterface $event)
{
foreach ($this->getListeners($event->getName()) as $listener) {
if (is_array($listener) && is_string($listener[0])) {
@ -63,7 +62,7 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherTrac
/**
* {@inheritDoc}
*/
public function notifyUntil(Event $event)
public function notifyUntil(EventInterface $event)
{
foreach ($this->getListeners($event->getName()) as $i => $listener) {
if (is_array($listener) && is_string($listener[0])) {
@ -93,7 +92,7 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherTrac
/**
* {@inheritDoc}
*/
public function filter(Event $event, $value)
public function filter(EventInterface $event, $value)
{
foreach ($this->getListeners($event->getName()) as $listener) {
if (is_array($listener) && is_string($listener[0])) {
@ -160,7 +159,7 @@ class EventDispatcher extends BaseEventDispatcher implements EventDispatcherTrac
}
}
protected function addCall(Event $event, $listener, $type)
protected function addCall(EventInterface $event, $listener, $type)
{
$listener = $this->listenerToString($listener);

View File

@ -181,7 +181,9 @@ class FrameworkExtension extends Extension
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver',
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
'Symfony\\Component\\EventDispatcher\\EventInterface',
'Symfony\\Component\\EventDispatcher\\Event',
'Symfony\\Component\\EventDispatcher\\EventDispatcherInterface',
'Symfony\\Component\\EventDispatcher\\EventDispatcher',
'Symfony\\Bundle\\FrameworkBundle\\EventDispatcher',

View File

@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle;
use Symfony\Component\EventDispatcher\EventDispatcher as BaseEventDispatcher;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventInterface;
/**
* This EventDispatcher automatically gets the kernel listeners injected
@ -42,7 +42,7 @@ class EventDispatcher extends BaseEventDispatcher
/**
* {@inheritdoc}
*/
public function notify(Event $event)
public function notify(EventInterface $event)
{
foreach ($this->getListeners($event->getName()) as $listener) {
if (is_array($listener) && is_string($listener[0])) {
@ -57,7 +57,7 @@ class EventDispatcher extends BaseEventDispatcher
/**
* {@inheritdoc}
*/
public function notifyUntil(Event $event)
public function notifyUntil(EventInterface $event)
{
foreach ($this->getListeners($event->getName()) as $listener) {
if (is_array($listener) && is_string($listener[0])) {
@ -75,7 +75,7 @@ class EventDispatcher extends BaseEventDispatcher
/**
* {@inheritdoc}
*/
public function filter(Event $event, $value)
public function filter(EventInterface $event, $value)
{
foreach ($this->getListeners($event->getName()) as $listener) {
if (is_array($listener) && is_string($listener[0])) {

View File

@ -7,7 +7,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\HttpKernel as BaseHttpKernel;
use Symfony\Component\EventDispatcher\EventDispatcher as BaseEventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* This HttpKernel is used to manage scope changes of the DI container.
@ -25,7 +25,7 @@ class HttpKernel extends BaseHttpKernel
$this->resolver = $controllerResolver;
}
public function setEventDispatcher(BaseEventDispatcher $dispatcher)
public function setEventDispatcher(EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
}

View File

@ -14,7 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -38,7 +38,7 @@ class RequestListener
$this->logger = $logger;
}
public function handle(Event $event)
public function handle(EventInterface $event)
{
$request = $event->get('request');
$master = HttpKernelInterface::MASTER_REQUEST === $event->get('request_type');

View File

@ -11,8 +11,7 @@
namespace Symfony\Bundle\WebProfilerBundle;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\HttpKernel;
@ -36,7 +35,7 @@ class WebDebugToolbarListener
$this->interceptRedirects = $interceptRedirects;
}
public function handle(Event $event, Response $response)
public function handle(EventInterface $event, Response $response)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type')) {
return $response;

View File

@ -16,7 +16,7 @@ namespace Symfony\Component\EventDispatcher;
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class Event
class Event implements EventInterface
{
protected $value = null;
protected $processed = false;

View File

@ -14,11 +14,9 @@ namespace Symfony\Component\EventDispatcher;
/**
* EventDispatcher implements a dispatcher object.
*
* @see http://developer.apple.com/documentation/Cocoa/Conceptual/Notifications/index.html Apple's Cocoa framework
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class EventDispatcher
class EventDispatcher implements EventDispatcherInterface
{
protected $listeners = array();
@ -46,8 +44,8 @@ class EventDispatcher
/**
* Disconnects one, or all listeners for the given event name.
*
* @param string $name An event name
* @param mixed|null $listener the listener to remove, or null to remove all
* @param string $name An event name
* @param mixed|null $listener The listener to remove, or null to remove all
*
* @return void
*/
@ -74,11 +72,11 @@ class EventDispatcher
/**
* Notifies all listeners of a given event.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*
* @return Event The Event instance
* @return EventInterface The EventInterface instance
*/
public function notify(Event $event)
public function notify(EventInterface $event)
{
foreach ($this->getListeners($event->getName()) as $listener) {
call_user_func($listener, $event);
@ -90,11 +88,11 @@ class EventDispatcher
/**
* Notifies all listeners of a given event until one returns a non null value.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*
* @return Event The Event instance
* @return EventInterface The EventInterface instance
*/
public function notifyUntil(Event $event)
public function notifyUntil(EventInterface $event)
{
foreach ($this->getListeners($event->getName()) as $listener) {
if (call_user_func($listener, $event)) {
@ -109,12 +107,12 @@ class EventDispatcher
/**
* Filters a value by calling all listeners of a given event.
*
* @param Event $event An Event instance
* @param mixed $value The value to be filtered
* @param EventInterface $event An EventInterface instance
* @param mixed $value The value to be filtered
*
* @return Event The Event instance
* @return EventInterface The EventInterface instance
*/
public function filter(Event $event, $value)
public function filter(EventInterface $event, $value)
{
foreach ($this->getListeners($event->getName()) as $listener) {
$value = call_user_func($listener, $event, $value);

View File

@ -0,0 +1,89 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\EventDispatcher;
/**
* EventDispatcherInterface describes an event dispatcher class.
*
* @see http://developer.apple.com/documentation/Cocoa/Conceptual/Notifications/index.html Apple's Cocoa framework
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
interface EventDispatcherInterface
{
/**
* Connects a listener to a given event name.
*
* Listeners with a higher priority are executed first.
*
* @param string $name An event name
* @param mixed $listener A PHP callable
* @param integer $priority The priority (between -10 and 10 -- defaults to 0)
*/
function connect($name, $listener, $priority = 0);
/**
* Disconnects one, or all listeners for the given event name.
*
* @param string $name An event name
* @param mixed|null $listener The listener to remove, or null to remove all
*
* @return void
*/
function disconnect($name, $listener = null);
/**
* Notifies all listeners of a given event.
*
* @param EventInterface $event An EventInterface instance
*
* @return EventInterface The EventInterface instance
*/
function notify(EventInterface $event);
/**
* Notifies all listeners of a given event until one returns a non null value.
*
* @param EventInterface $event An EventInterface instance
*
* @return EventInterface The EventInterface instance
*/
function notifyUntil(EventInterface $event);
/**
* Filters a value by calling all listeners of a given event.
*
* @param EventInterface $event An EventInterface instance
* @param mixed $value The value to be filtered
*
* @return EventInterface The EventInterface instance
*/
function filter(EventInterface $event, $value);
/**
* Returns true if the given event name has some listeners.
*
* @param string $name The event name
*
* @return Boolean true if some listeners are connected, false otherwise
*/
function hasListeners($name);
/**
* Returns all listeners associated with a given event name.
*
* @param string $name The event name
*
* @return array An array of listeners
*/
function getListeners($name);
}

View File

@ -0,0 +1,97 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\EventDispatcher;
/**
* EventInterface.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
interface EventInterface
{
/**
* Returns the subject.
*
* @return mixed The subject
*/
function getSubject();
/**
* Returns the event name.
*
* @return string The event name
*/
function getName();
/**
* Sets the return value for this event.
*
* @param mixed $value The return value
*/
function setReturnValue($value);
/**
* Returns the return value.
*
* @return mixed The return value
*/
function getReturnValue();
/**
* Sets the processed flag.
*
* @param Boolean $processed The processed flag value
*/
function setProcessed($processed);
/**
* Returns whether the event has been processed by a listener or not.
*
* @return Boolean true if the event has been processed, false otherwise
*/
function isProcessed();
/**
* Returns the event parameters.
*
* @return array The event parameters
*/
function all();
/**
* Returns true if the parameter exists.
*
* @param string $name The parameter name
*
* @return Boolean true if the parameter exists, false otherwise
*/
function has($name);
/**
* Returns a parameter value.
*
* @param string $name The parameter name
*
* @return mixed The parameter value
*
* @throws \InvalidArgumentException When parameter doesn't exists for this event
*/
function get($name);
/**
* Sets a parameter.
*
* @param string $name The parameter name
* @param mixed $value The parameter value
*/
function set($name, $value);
}

View File

@ -13,7 +13,8 @@ namespace Symfony\Component\HttpKernel\Cache;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
/**
* EsiListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for ESI.
@ -40,10 +41,10 @@ class EsiListener
/**
* Filters the Response.
*
* @param Event $event An Event instance
* @param Response $response A Response instance
* @param EventInterface $event An EventInterface instance
* @param Response $response A Response instance
*/
public function filter($event, Response $response)
public function filter(EventInterface $event, Response $response)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type') || null === $this->esi) {
return $response;

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\DataCollector;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Debug\EventDispatcherTraceableInterface;
@ -25,7 +25,7 @@ class EventDataCollector extends DataCollector
{
protected $dispatcher;
public function setEventDispatcher(EventDispatcher $dispatcher)
public function setEventDispatcher(EventDispatcherInterface $dispatcher)
{
if ($dispatcher instanceof EventDispatcherTraceableInterface) {
$this->dispatcher = $dispatcher;

View File

@ -11,7 +11,6 @@
namespace Symfony\Component\HttpKernel\DataCollector;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

View File

@ -11,8 +11,7 @@
namespace Symfony\Component\HttpKernel\Debug;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@ -37,7 +36,7 @@ class ExceptionListener
$this->logger = $logger;
}
public function handle(Event $event)
public function handle(EventInterface $event)
{
static $handling;

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\HttpKernel;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Request;
@ -31,10 +31,10 @@ class HttpKernel implements HttpKernelInterface
/**
* Constructor
*
* @param EventDispatcher $dispatcher An event dispatcher instance
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param ControllerResolverInterface $resolver A ControllerResolverInterface instance
*/
public function __construct(EventDispatcher $dispatcher, ControllerResolverInterface $resolver)
public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver)
{
$this->dispatcher = $dispatcher;
$this->resolver = $resolver;

View File

@ -11,8 +11,7 @@
namespace Symfony\Component\HttpKernel\Profiler;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
@ -49,9 +48,9 @@ class ProfilerListener
/**
* Handles the core.exception event.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handleException(Event $event)
public function handleException(EventInterface $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type')) {
return false;
@ -65,11 +64,11 @@ class ProfilerListener
/**
* Handles the core.response event.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*
* @return Response $response A Response instance
*/
public function handleResponse(Event $event, Response $response)
public function handleResponse(EventInterface $event, Response $response)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type')) {
return $response;

View File

@ -11,8 +11,7 @@
namespace Symfony\Component\HttpKernel;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\HttpFoundation\Response;
/**
@ -27,10 +26,10 @@ class ResponseListener
/**
* Filters the Response.
*
* @param Event $event An Event instance
* @param Response $response A Response instance
* @param EventInterface $event An EventInterface instance
* @param Response $response A Response instance
*/
public function filter(Event $event, Response $response)
public function filter(EventInterface $event, Response $response)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type') || $response->headers->has('Content-Type')) {
return $response;

View File

@ -11,7 +11,8 @@
namespace Symfony\Component\HttpKernel\Security;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
@ -39,7 +40,7 @@ class Firewall
*
* @param FirewallMap $map A FirewallMap instance
*/
public function __construct(FirewallMapInterface $map, EventDispatcher $dispatcher)
public function __construct(FirewallMapInterface $map, EventDispatcherInterface $dispatcher)
{
$this->map = $map;
$this->dispatcher = $dispatcher;
@ -49,9 +50,9 @@ class Firewall
/**
* Handles security.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type')) {
return;

View File

@ -16,8 +16,8 @@ use Symfony\Component\Security\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\HttpKernel\Security\AccessMap;
use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\Security\Exception\AuthenticationCredentialsNotFoundException;
use Symfony\Component\Security\Exception\AccessDeniedException;
@ -46,10 +46,10 @@ class AccessListener implements ListenerInterface
/**
* Registers a core.security listener to enforce authorization rules.
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'handle'), 0);
}
@ -57,16 +57,16 @@ class AccessListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
}
/**
* Handles access authorization.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
if (null === $token = $this->context->getToken()) {
throw new AuthenticationCredentialsNotFoundException('A Token was not found in the SecurityContext.');

View File

@ -13,8 +13,8 @@ namespace Symfony\Component\HttpKernel\Security\Firewall;
use Symfony\Component\Security\SecurityContext;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\Security\Authentication\Token\AnonymousToken;
/**
@ -40,10 +40,10 @@ class AnonymousAuthenticationListener implements ListenerInterface
* Registers a core.security listener to load the SecurityContext from the
* session.
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'handle'), 0);
}
@ -51,16 +51,16 @@ class AnonymousAuthenticationListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
}
/**
* Handles anonymous authentication.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
$request = $event->get('request');

View File

@ -15,8 +15,8 @@ use Symfony\Component\Security\SecurityContext;
use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Authentication\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Exception\AuthenticationException;
@ -45,10 +45,10 @@ class BasicAuthenticationListener implements ListenerInterface
/**
*
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'handle'), 0);
}
@ -56,16 +56,16 @@ class BasicAuthenticationListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
}
/**
* Handles basic authentication.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
$request = $event->get('request');

View File

@ -14,8 +14,8 @@ namespace Symfony\Component\HttpKernel\Security\Firewall;
use Symfony\Component\HttpKernel\Security\AccessMap;
use Symfony\Component\Security\Authentication\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
/**
* ChannelListener switches the HTTP protocol based on the access control
@ -39,10 +39,10 @@ class ChannelListener implements ListenerInterface
/**
*
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'handle'), 0);
}
@ -50,16 +50,16 @@ class ChannelListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
}
/**
* Handles channel management.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
$request = $event->get('request');

View File

@ -11,8 +11,8 @@
namespace Symfony\Component\HttpKernel\Security\Firewall;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
@ -46,10 +46,10 @@ class ContextListener implements ListenerInterface
* Registers a core.security listener to load the SecurityContext from the
* session.
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'read'), 0);
$dispatcher->connect('core.response', array($this, 'write'), 0);
@ -58,7 +58,7 @@ class ContextListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
$dispatcher->disconnect('core.response', array($this, 'write'));
}
@ -66,9 +66,9 @@ class ContextListener implements ListenerInterface
/**
* Reads the SecurityContext from the session.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function read(Event $event)
public function read(EventInterface $event)
{
$request = $event->get('request');
@ -94,9 +94,9 @@ class ContextListener implements ListenerInterface
/**
* Writes the SecurityContext to the session.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function write(Event $event, Response $response)
public function write(EventInterface $event, Response $response)
{
if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type')) {
return $response;

View File

@ -15,8 +15,8 @@ use Symfony\Component\Security\SecurityContext;
use Symfony\Component\Security\User\UserProviderInterface;
use Symfony\Component\HttpKernel\Security\EntryPoint\DigestAuthenticationEntryPoint;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\Security\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Exception\BadCredentialsException;
use Symfony\Component\Security\Exception\AuthenticationServiceException;
@ -48,10 +48,10 @@ class DigestAuthenticationListener implements ListenerInterface
/**
*
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'handle'), 0);
}
@ -59,16 +59,16 @@ class DigestAuthenticationListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
}
/**
* Handles digest authentication.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
$request = $event->get('request');

View File

@ -15,8 +15,8 @@ use Symfony\Component\Security\SecurityContext;
use Symfony\Component\Security\Authentication\AuthenticationTrustResolverInterface;
use Symfony\Component\Security\Authentication\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\Security\Exception\AuthenticationException;
use Symfony\Component\Security\Exception\AccessDeniedException;
use Symfony\Component\Security\Authentication\Token\AnonymousToken;
@ -50,10 +50,10 @@ class ExceptionListener implements ListenerInterface
/**
* Registers a core.exception listener to take care of security exceptions.
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.exception', array($this, 'handleException'), 0);
}
@ -61,7 +61,7 @@ class ExceptionListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
$dispatcher->disconnect('core.exception', array($this, 'handleException'));
}
@ -69,9 +69,9 @@ class ExceptionListener implements ListenerInterface
/**
* Handles security related exceptions.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handleException(Event $event)
public function handleException(EventInterface $event)
{
$exception = $event->get('exception');
$request = $event->get('request');

View File

@ -14,8 +14,8 @@ namespace Symfony\Component\HttpKernel\Security\Firewall;
use Symfony\Component\Security\SecurityContext;
use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\Security\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@ -62,10 +62,10 @@ abstract class FormAuthenticationListener
/**
*
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'handle'), 0);
}
@ -73,16 +73,16 @@ abstract class FormAuthenticationListener
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
}
/**
* Handles form based authentication.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
$request = $event->get('request');

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel\Security\Firewall;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Interface that must be implemented by firewall listeners
@ -22,23 +22,21 @@ interface ListenerInterface
{
/**
* The implementation must connect this listener to all necessary events.
*
*
* Typical events are: "core.security", and "core.response"
*
* @param EventDispatcher $dispatcher
* @return void
*
* @param EventDispatcherInterface $dispatcher
*/
function register(EventDispatcher $dispatcher);
function register(EventDispatcherInterface $dispatcher);
/**
* The implementation must remove this listener from any events that it had
* connected to in register().
*
*
* It may remove this listener from "core.security", but this is ensured by
* the firewall anyway.
*
* @param EventDispatcher $dispatcher
* @return void
*
* @param EventDispatcherInterface $dispatcher
*/
function unregister(EventDispatcher $dispatcher);
function unregister(EventDispatcherInterface $dispatcher);
}

View File

@ -13,8 +13,8 @@ namespace Symfony\Component\HttpKernel\Security\Firewall;
use Symfony\Component\HttpKernel\Security\Logout\LogoutHandlerInterface;
use Symfony\Component\Security\SecurityContext;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\HttpFoundation\Response;
/**
@ -58,10 +58,10 @@ class LogoutListener implements ListenerInterface
/**
* Registers a core.security listener.
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'handle'), 0);
}
@ -69,16 +69,16 @@ class LogoutListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
}
/**
* Performs the logout if requested
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
$request = $event->get('request');

View File

@ -14,8 +14,8 @@ namespace Symfony\Component\HttpKernel\Security\Firewall;
use Symfony\Component\Security\SecurityContext;
use Symfony\Component\Security\Authentication\AuthenticationManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\Security\Authentication\Token\PreAuthenticatedToken;
use Symfony\Component\Security\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Request;
@ -43,10 +43,10 @@ abstract class PreAuthenticatedListener implements ListenerInterface
/**
*
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'handle'), 0);
}
@ -54,16 +54,16 @@ abstract class PreAuthenticatedListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
}
/**
* Handles X509 authentication.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
$request = $event->get('request');

View File

@ -16,8 +16,8 @@ use Symfony\Component\Security\User\UserProviderInterface;
use Symfony\Component\Security\User\AccountCheckerInterface;
use Symfony\Component\Security\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventInterface;
use Symfony\Component\Security\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
@ -59,10 +59,10 @@ class SwitchUserListener implements ListenerInterface
/**
*
*
* @param EventDispatcher $dispatcher An EventDispatcher instance
* @param integer $priority The priority
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param integer $priority The priority
*/
public function register(EventDispatcher $dispatcher)
public function register(EventDispatcherInterface $dispatcher)
{
$dispatcher->connect('core.security', array($this, 'handle'), 0);
}
@ -70,16 +70,16 @@ class SwitchUserListener implements ListenerInterface
/**
* {@inheritDoc}
*/
public function unregister(EventDispatcher $dispatcher)
public function unregister(EventDispatcherInterface $dispatcher)
{
}
/**
* Handles digest authentication.
*
* @param Event $event An Event instance
* @param EventInterface $event An EventInterface instance
*/
public function handle(Event $event)
public function handle(EventInterface $event)
{
$request = $event->get('request');