Switched from Doctrine's EventManager implementation to the EventManager clone in Symfony2 (now called EventDispatcher again)

This commit is contained in:
Bernhard Schussek 2011-03-13 19:16:56 +01:00
parent 699e046b4f
commit 06c682b4fb
74 changed files with 417 additions and 418 deletions

View File

@ -14,27 +14,27 @@ namespace Symfony\Bundle\AsseticBundle\CacheWarmer;
use Assetic\AssetManager;
use Assetic\AssetWriter;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer;
use Symfony\Bundle\AsseticBundle\Event\WriteEventArgs;
use Symfony\Bundle\AsseticBundle\Event\WriteEvent;
use Symfony\Bundle\AsseticBundle\Events;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class AssetWriterCacheWarmer extends CacheWarmer
{
protected $am;
protected $writer;
protected $evm;
protected $dispatcher;
public function __construct(AssetManager $am, AssetWriter $writer, EventManager $evm)
public function __construct(AssetManager $am, AssetWriter $writer, EventDispatcherInterface $dispatcher)
{
$this->am = $am;
$this->writer = $writer;
$this->evm = $evm;
$this->dispatcher = $dispatcher;
}
public function warmUp($cacheDir)
{
// notify an event so custom stream wrappers can be registered lazily
$this->evm->dispatchEvent(Events::onAsseticWrite, new WriteEventArgs());
$this->dispatcher->dispatchEvent(Events::onAsseticWrite, new WriteEvent());
$this->writer->writeManagerAssets($this->am);
}

View File

@ -14,13 +14,12 @@ namespace Symfony\Bundle\AsseticBundle\Command;
use Assetic\Asset\AssetInterface;
use Assetic\Factory\LazyAssetManager;
use Symfony\Bundle\FrameworkBundle\Command\Command;
use Symfony\Bundle\AsseticBundle\Event\WriteEventArgs;
use Symfony\Bundle\AsseticBundle\Event\WriteEvent;
use Symfony\Bundle\AsseticBundle\Events;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\Common\EventManager;
/**
* Dumps assets to the filesystem.
@ -48,8 +47,8 @@ class DumpCommand extends Command
$am = $this->container->get('assetic.asset_manager');
// notify an event so custom stream wrappers can be registered lazily
$eventArgs = new WriteEventArgs($basePath);
$this->container->get('event_manager')->dispatchEvent(Events::onAsseticWrite, $writeEventArgs);
$event = new WriteEvent($basePath);
$this->container->get('event_dispatcher')->dispatchEvent(Events::onAsseticWrite, $writeEvent);
if ($input->getOption('watch')) {
return $this->watch($am, $basePath, $output, $this->container->getParameter('kernel.debug'));

View File

@ -11,12 +11,12 @@
namespace Symfony\Bundle\AsseticBundle\Event;
use Doctrine\Common\EventArgs;
use Symfony\Component\EventDispatcher\Event;
/**
* @author Bernhard Schussek <bernhard.schussek@symfony-project.com>
*/
class WriteEventArgs extends EventArgs
class WriteEvent extends Event
{
private $targetPath;

View File

@ -14,7 +14,7 @@
<tag name="kernel.cache_warmer" />
<argument type="service" id="assetic.asset_manager" />
<argument type="service" id="assetic.asset_writer" />
<argument type="service" id="event_manager" />
<argument type="service" id="event_dispatcher" />
</service>
<service id="assetic.asset_writer" class="%assetic.asset_writer.class%" public="false">
<argument>%assetic.write_to%</argument>

View File

@ -12,7 +12,7 @@
namespace Symfony\Bundle\AsseticBundle\Tests\CacheWarmer;
use Symfony\Bundle\AsseticBundle\CacheWarmer\AssetWriterCacheWarmer;
use Symfony\Bundle\AsseticBundle\Event\WriteEventArgs;
use Symfony\Bundle\AsseticBundle\Event\WriteEvent;
use Symfony\Bundle\AsseticBundle\Events;
class AssetWriterCacheWarmerTest extends \PHPUnit_Framework_TestCase
@ -30,18 +30,18 @@ class AssetWriterCacheWarmerTest extends \PHPUnit_Framework_TestCase
$writer = $this->getMockBuilder('Assetic\\AssetWriter')
->disableOriginalConstructor()
->getMock();
$evm = $this->getMock('Doctrine\\Common\\EventManager');
$dispatcher = $this->getMock('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface');
$eventArgs = new WriteEventArgs();
$event = new WriteEvent();
$evm->expects($this->once())
$dispatcher->expects($this->once())
->method('dispatchEvent')
->with(Events::onAsseticWrite, $eventArgs);
->with(Events::onAsseticWrite, $event);
$writer->expects($this->once())
->method('writeManagerAssets')
->with($am);
$warmer = new AssetWriterCacheWarmer($am, $writer, $evm);
$warmer = new AssetWriterCacheWarmer($am, $writer, $dispatcher);
$warmer->warmUp('/path/to/cache');
}
}

View File

@ -36,7 +36,7 @@ class ConnectionFactory
/**
* Create a connection by name.
*
*
* @param string $connectionName
* @return Doctrine\DBAL\Connection
*/

View File

@ -12,8 +12,8 @@
namespace Symfony\Bundle\FrameworkBundle;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Doctrine\Common\EventManager;
use Doctrine\Common\EventArgs;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
/**
* Lazily loads listeners and subscribers from the dependency injection
@ -22,7 +22,7 @@ use Doctrine\Common\EventArgs;
* @author Fabien Potencier <fabien@symfony.com>
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
*/
class ContainerAwareEventManager extends EventManager
class ContainerAwareEventDispatcher extends EventDispatcher
{
/**
* The container from where services are loaded
@ -92,7 +92,7 @@ class ContainerAwareEventManager extends EventManager
* Lazily loads listeners for this event from the dependency injection
* container.
*/
public function dispatchEvent($eventName, EventArgs $eventArgs = null)
public function dispatchEvent($eventName, Event $event = null)
{
if (isset($this->listenerIds[$eventName])) {
foreach ($this->listenerIds[$eventName] as $serviceId => $priority) {
@ -100,6 +100,6 @@ class ContainerAwareEventManager extends EventManager
}
}
parent::dispatchEvent($eventName, $eventArgs);
parent::dispatchEvent($eventName, $event);
}
}

View File

@ -11,18 +11,18 @@
namespace Symfony\Bundle\FrameworkBundle\Debug;
use Symfony\Bundle\FrameworkBundle\ContainerAwareEventManager;
use Symfony\Bundle\FrameworkBundle\ContainerAwareEventDispatcher;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Debug\TraceableEventManagerInterface;
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcherInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Doctrine\Common\EventArgs;
use Symfony\Component\EventDispatcher\Event;
/**
* Extends the ContainerAwareEventManager to add some debugging tools.
* Extends the ContainerAwareEventDispatcher to add some debugging tools.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class TraceableEventManager extends ContainerAwareEventManager implements TraceableEventManagerInterface
class TraceableEventDispatcher extends ContainerAwareEventDispatcher implements TraceableEventDispatcherInterface
{
protected $logger;
protected $called;
@ -44,9 +44,9 @@ class TraceableEventManager extends ContainerAwareEventManager implements Tracea
/**
* {@inheritDoc}
*/
protected function triggerListener($listener, $eventName, EventArgs $eventArgs)
protected function triggerListener($listener, $eventName, Event $event)
{
parent::triggerListener($listener, $eventName, $eventArgs);
parent::triggerListener($listener, $eventName, $event);
$listenerString = $this->listenerToString($listener);
@ -59,7 +59,7 @@ class TraceableEventManager extends ContainerAwareEventManager implements Tracea
'listener' => $listenerString,
);
if ($eventArgs->isPropagationStopped() && null !== $this->logger) {
if ($event->isPropagationStopped() && null !== $this->logger) {
$this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s"', $this->listenerToString($listener), $eventName));
$skippedListeners = $this->getListeners($eventName);

View File

@ -19,12 +19,12 @@ class RegisterKernelListenersPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('event_manager')) {
if (!$container->hasDefinition('event_dispatcher')) {
return;
}
$listeners = array();
$definition = $container->getDefinition('event_manager');
$definition = $container->getDefinition('event_dispatcher');
foreach ($container->findTaggedServiceIds('kernel.listener') as $id => $events) {
foreach ($events as $event) {

View File

@ -51,8 +51,8 @@ class FrameworkExtension extends Extension
if ($container->getParameter('kernel.debug')) {
$loader->load('debug.xml');
$container->setDefinition('event_manager', $container->findDefinition('debug.event_manager'));
$container->setAlias('debug.event_manager', 'event_manager');
$container->setDefinition('event_dispatcher', $container->findDefinition('debug.event_dispatcher'));
$container->setAlias('debug.event_dispatcher', 'event_dispatcher');
}
$processor = new Processor();
@ -140,12 +140,12 @@ class FrameworkExtension extends Extension
'Symfony\\Component\\HttpKernel\\ResponseListener',
'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver',
'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface',
'Symfony\\Component\\HttpKernel\\Event\\KernelEventArgs',
'Symfony\\Component\\HttpKernel\\Event\\FilterControllerEventArgs',
'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEventArgs',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseEventArgs',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEventArgs',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEventArgs',
'Symfony\\Component\\HttpKernel\\Event\\KernelEvent',
'Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent',
'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent',
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent',
'Symfony\\Component\\HttpKernel\\Events',
'Symfony\\Bundle\\FrameworkBundle\\RequestListener',
@ -153,11 +153,12 @@ class FrameworkExtension extends Extension
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver',
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
'Symfony\\Bundle\\FrameworkBundle\\ContainerAwareEventManager',
'Symfony\\Bundle\\FrameworkBundle\\ContainerAwareEventDispatcher',
'Doctrine\\Common\\EventManager',
'Doctrine\\Common\\EventArgs',
'Doctrine\\Common\\EventSubscriber',
'Symfony\\Component\\EventDispatcher\\EventDispatcher',
'Symfony\\Component\\EventDispatcher\\EventDispatcherInterface',
'Symfony\\Component\\EventDispatcher\\Event',
'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface',
));
}

View File

@ -14,7 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\HttpFoundation;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/**
* SessionListener.
@ -29,12 +29,12 @@ class SessionListener
* Checks if session was initialized and saves if current request is master
* Runs on 'filterCoreResponse' in test environment
*
* @param FilterResponseEventArgs $eventArgs
* @param FilterResponseEvent $event
*/
public function filterCoreResponse(FilterResponseEventArgs $eventArgs)
public function filterCoreResponse(FilterResponseEvent $event)
{
if ($request = $eventArgs->getRequest()) {
if (HttpKernelInterface::MASTER_REQUEST === $eventArgs->getRequestType()) {
if ($request = $event->getRequest()) {
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
if ($session = $request->getSession()) {
$session->save();
}

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 Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* This HttpKernel is used to manage scope changes of the DI container.
@ -19,9 +19,9 @@ class HttpKernel extends BaseHttpKernel
private $container;
private $esiSupport;
public function __construct(EventManager $evm, ContainerInterface $container, ControllerResolverInterface $controllerResolver)
public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver)
{
parent::__construct($evm, $controllerResolver);
parent::__construct($dispatcher, $controllerResolver);
$this->container = $container;
}

View File

@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Profiler;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -46,29 +46,29 @@ class ProfilerListener
/**
* Handles the onCoreException event.
*
* @param ExceptionEventArgs $eventArgs An ExceptionEventArgs instance
* @param ExceptionEvent $event An ExceptionEvent instance
*/
public function onCoreException(ExceptionEventArgs $eventArgs)
public function onCoreException(ExceptionEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $eventArgs->getRequestType()) {
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
$this->exception = $eventArgs->getException();
$this->exception = $event->getException();
}
/**
* Handles the filterCoreResponse event.
*
* @param FilterResponseEventArgs $eventArgs A FilterResponseEventArgs instance
* @param FilterResponseEvent $event A FilterResponseEvent instance
*/
public function filterCoreResponse(FilterResponseEventArgs $eventArgs)
public function filterCoreResponse(FilterResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $eventArgs->getRequestType()) {
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
if (null !== $this->matcher && !$this->matcher->matches($eventArgs->getRequest())) {
if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) {
return;
}
@ -76,7 +76,7 @@ class ProfilerListener
return;
}
$this->container->get('profiler')->collect($eventArgs->getRequest(), $response, $this->exception);
$this->container->get('profiler')->collect($event->getRequest(), $response, $this->exception);
$this->exception = null;
}
}

View File

@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -36,10 +36,10 @@ class RequestListener
$this->logger = $logger;
}
public function onCoreRequest(GetResponseEventArgs $eventArgs)
public function onCoreRequest(GetResponseEvent $event)
{
$request = $eventArgs->getRequest();
$master = HttpKernelInterface::MASTER_REQUEST === $eventArgs->getRequestType();
$request = $event->getRequest();
$master = HttpKernelInterface::MASTER_REQUEST === $event->getRequestType();
$this->initializeSession($request, $master);

View File

@ -30,8 +30,8 @@
<service id="data_collector.events" class="%data_collector.events.class%" public="false">
<tag name="data_collector" template="WebProfilerBundle:Collector:events" id="events" priority="255" />
<call method="setEventManager">
<argument type="service" id="event_manager" />
<call method="setEventDispatcher">
<argument type="service" id="event_dispatcher" />
</call>
</service>

View File

@ -5,11 +5,11 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="debug.event_manager.class">Symfony\Bundle\FrameworkBundle\Debug\TraceableEventManager</parameter>
<parameter key="debug.event_dispatcher.class">Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher</parameter>
</parameters>
<services>
<service id="debug.event_manager" class="%debug.event_manager.class%">
<service id="debug.event_dispatcher" class="%debug.event_dispatcher.class%">
<argument type="service" id="service_container" />
<argument type="service" id="logger" on-invalid="null" />
</service>

View File

@ -5,7 +5,7 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="event_manager.class">Symfony\Bundle\FrameworkBundle\ContainerAwareEventManager</parameter>
<parameter key="event_dispatcher.class">Symfony\Bundle\FrameworkBundle\ContainerAwareEventDispatcher</parameter>
<parameter key="http_kernel.class">Symfony\Bundle\FrameworkBundle\HttpKernel</parameter>
<parameter key="error_handler.class">Symfony\Component\HttpKernel\Debug\ErrorHandler</parameter>
<parameter key="error_handler.level">null</parameter>
@ -16,7 +16,7 @@
</parameters>
<services>
<service id="event_manager" class="%event_manager.class%">
<service id="event_dispatcher" class="%event_dispatcher.class%">
<argument type="service" id="service_container" />
</service>
@ -25,7 +25,7 @@
</service>
<service id="http_kernel" class="%http_kernel.class%">
<argument type="service" id="event_manager" />
<argument type="service" id="event_dispatcher" />
<argument type="service" id="service_container" />
<argument type="service" id="controller_resolver" />
</service>

View File

@ -15,7 +15,7 @@ use Symfony\Bundle\FrameworkBundle\HttpFoundation\SessionListener;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/**
* SessionListenerTest.
@ -54,11 +54,11 @@ class SessionListenerTest extends \PHPUnit_Framework_TestCase
$request->setSession($this->session);
$response = new Response();
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$eventArgs = new FilterResponseEventArgs($kernel, $request, $type, $response);
$event = new FilterResponseEvent($kernel, $request, $type, $response);
$this->listener->filterCoreResponse($eventArgs);
$this->listener->filterCoreResponse($event);
$this->assertSame($response, $eventArgs->getResponse());
$this->assertSame($response, $event->getResponse());
}
private function sessionMustNotBeSaved()

View File

@ -7,7 +7,7 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Bundle\FrameworkBundle\HttpKernel;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
class HttpKernelTest extends \PHPUnit_Framework_TestCase
{
@ -36,9 +36,9 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request'))
;
$evm = new EventManager();
$dispatcher = new EventDispatcher();
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
$kernel = new HttpKernel($evm, $container, $resolver);
$kernel = new HttpKernel($dispatcher, $container, $resolver);
$controller = function() use($expected)
{
@ -84,9 +84,9 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request'))
;
$evm = new EventManager();
$dispatcher = new EventDispatcher();
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
$kernel = new HttpKernel($evm, $container, $resolver);
$kernel = new HttpKernel($dispatcher, $container, $resolver);
$controller = function() use ($expected)
{

View File

@ -108,7 +108,7 @@
<service id="security.firewall" class="%security.firewall.class%">
<tag name="kernel.listener" event="onCoreRequest" priority="-128" />
<argument type="service" id="security.firewall.map" />
<argument type="service" id="event_manager" />
<argument type="service" id="event_dispatcher" />
</service>
<service id="security.firewall.map" class="%security.firewall.map.class%" public="false">

View File

@ -3,7 +3,7 @@
namespace Symfony\Bundle\SecurityBundle;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
/**
@ -13,10 +13,10 @@ use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
*/
class ResponseListener
{
public function filterCoreResponse(FilterResponseEventArgs $eventArgs)
public function filterCoreResponse(FilterResponseEvent $event)
{
$request = $eventArgs->getRequest();
$response = $eventArgs->getResponse();
$request = $event->getRequest();
$response = $event->getResponse();
if ($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME)) {
$response->headers->setCookie($request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME));

View File

@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Bundle\TwigBundle\TwigEngine;
/**
@ -41,14 +41,14 @@ class WebDebugToolbarListener
$this->interceptRedirects = $interceptRedirects;
}
public function filterCoreResponse(FilterResponseEventArgs $eventArgs)
public function filterCoreResponse(FilterResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $eventArgs->getRequestType()) {
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
$response = $eventArgs->getResponse();
$request = $eventArgs->getRequest();
$response = $event->getResponse();
$request = $event->getRequest();
if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects) {
// keep current flashes for one more request

View File

@ -23,7 +23,7 @@
namespace Symfony\Component\EventDispatcher;
/**
* The EventManager is the central point of Doctrine's event listener system.
* The EventDispatcherInterface is the central point of Doctrine's event listener system.
* Listeners are registered on the manager and events are dispatched through the
* manager.
*

View File

@ -12,7 +12,7 @@
namespace Symfony\Component\EventDispatcher;
/**
* The EventManager is the central point of Doctrine's event listener system.
* The EventDispatcherInterface is the central point of Doctrine's event listener system.
* Listeners are registered on the manager and events are dispatched through the
* manager.
*

View File

@ -24,7 +24,7 @@ namespace Symfony\Component\EventDispatcher;
/**
* An EventSubscriber knows himself what events he is interested in.
* If an EventSubscriber is added to an EventManager, the manager invokes
* If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes
* {@link getSubscribedEvents} and registers the subscriber as a listener for all
* returned events.
*

View File

@ -13,8 +13,8 @@ namespace Symfony\Component\HttpKernel\DataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Debug\TraceableEventManagerInterface;
use Doctrine\Common\EventManager;
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* EventDataCollector.
@ -23,12 +23,12 @@ use Doctrine\Common\EventManager;
*/
class EventDataCollector extends DataCollector
{
protected $evm;
protected $dispatcher;
public function setEventManager(EventManager $evm)
public function setEventDispatcher(EventDispatcherInterface $dispatcher)
{
if ($evm instanceof TraceableEventManagerInterface) {
$this->evm = $evm;
if ($dispatcher instanceof TraceableEventDispatcherInterface) {
$this->dispatcher = $dispatcher;
}
}
@ -38,8 +38,8 @@ class EventDataCollector extends DataCollector
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = array(
'called_listeners' => null !== $this->evm ? $this->evm->getCalledListeners() : array(),
'not_called_listeners' => null !== $this->evm ? $this->evm->getNotCalledListeners() : array(),
'called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getCalledListeners() : array(),
'not_called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getNotCalledListeners() : array(),
);
}
@ -48,7 +48,7 @@ class EventDataCollector extends DataCollector
*
* @return array An array of called listeners
*
* @see TraceableEventManagerInterface
* @see TraceableEventDispatcherInterface
*/
public function getCalledListeners()
{
@ -60,7 +60,7 @@ class EventDataCollector extends DataCollector
*
* @return array An array of not called listeners
*
* @see TraceableEventManagerInterface
* @see TraceableEventDispatcherInterface
*/
public function getNotCalledListeners()
{

View File

@ -48,7 +48,7 @@ class LoggerDataCollector extends DataCollector
*
* @return array An array of called events
*
* @see TraceableEventManagerInterface
* @see TraceableEventDispatcherInterface
*/
public function countErrors()
{

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\Debug;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Exception\FlattenException;
use Symfony\Component\HttpFoundation\Request;
@ -34,7 +34,7 @@ class ExceptionListener
$this->logger = $logger;
}
public function onCoreException(GetResponseForExceptionEventArgs $eventArgs)
public function onCoreException(GetResponseForExceptionEvent $event)
{
static $handling;
@ -44,8 +44,8 @@ class ExceptionListener
$handling = true;
$exception = $eventArgs->getException();
$request = $eventArgs->getRequest();
$exception = $event->getException();
$request = $event->getRequest();
if (null !== $this->logger) {
$this->logger->err(sprintf('%s: %s (uncaught exception)', get_class($exception), $exception->getMessage()));
@ -66,7 +66,7 @@ class ExceptionListener
$request = $request->duplicate(null, null, $attributes);
try {
$response = $eventArgs->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, true);
$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, true);
} catch (\Exception $e) {
$message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
if (null !== $this->logger) {
@ -82,7 +82,7 @@ class ExceptionListener
throw $exception;
}
$eventArgs->setResponse($response);
$event->setResponse($response);
$handling = false;
}

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Debug;
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
interface TraceableEventManagerInterface
interface TraceableEventDispatcherInterface
{
/**
* Gets the called listeners.

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Event;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
class FilterControllerEventArgs extends KernelEventArgs
class FilterControllerEvent extends KernelEvent
{
private $controller;

View File

@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class FilterResponseEventArgs extends KernelEventArgs
class FilterResponseEvent extends KernelEvent
{
private $response;

View File

@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class GetResponseEventArgs extends KernelEventArgs
class GetResponseEvent extends KernelEvent
{
private $response;

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Event;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
class GetResponseForControllerResultEventArgs extends GetResponseEventArgs
class GetResponseForControllerResultEvent extends GetResponseEvent
{
private $controllerResult;

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Event;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
class GetResponseForExceptionEventArgs extends GetResponseEventArgs
class GetResponseForExceptionEvent extends GetResponseEvent
{
private $exception;

View File

@ -13,9 +13,9 @@ namespace Symfony\Component\HttpKernel\Event;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\Common\EventArgs;
use Symfony\Component\EventDispatcher\Event;
class KernelEventArgs extends EventArgs
class KernelEvent extends Event
{
private $kernel;

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\HttpCache;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
/**
* EsiListener adds a Surrogate-Control HTTP header when the Response needs to be parsed for ESI.
@ -38,14 +38,14 @@ class EsiListener
/**
* Filters the Response.
*
* @param FilterResponseEventArgs $eventArgs A FilterResponseEventArgs instance
* @param FilterResponseEvent $event A FilterResponseEvent instance
*/
public function filterCoreResponse(FilterResponseEventArgs $eventArgs)
public function filterCoreResponse(FilterResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $eventArgs->getRequestType() || null === $this->esi) {
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType() || null === $this->esi) {
return;
}
$this->esi->addSurrogateControl($eventArgs->getResponse());
$this->esi->addSurrogateControl($event->getResponse());
}
}

View File

@ -13,14 +13,14 @@ namespace Symfony\Component\HttpKernel;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Event\FilterControllerEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEventArgs;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* HttpKernel notifies events to convert a Request object to a Response one.
@ -29,18 +29,18 @@ use Doctrine\Common\EventManager;
*/
class HttpKernel implements HttpKernelInterface
{
private $evm;
private $dispatcher;
private $resolver;
/**
* Constructor
*
* @param EventManager $evm An EventManager instance
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
* @param ControllerResolverInterface $resolver A ControllerResolverInterface instance
*/
public function __construct(EventManager $evm, ControllerResolverInterface $resolver)
public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver)
{
$this->evm = $evm;
$this->dispatcher = $dispatcher;
$this->resolver = $resolver;
}
@ -57,14 +57,14 @@ class HttpKernel implements HttpKernelInterface
}
// exception
$eventArgs = new GetResponseForExceptionEventArgs($this, $request, $type, $e);
$this->evm->dispatchEvent(Events::onCoreException, $eventArgs);
$event = new GetResponseForExceptionEvent($this, $request, $type, $e);
$this->dispatcher->dispatchEvent(Events::onCoreException, $event);
if (!$eventArgs->hasResponse()) {
if (!$event->hasResponse()) {
throw $e;
}
$response = $this->filterResponse($eventArgs->getResponse(), $request, $type);
$response = $this->filterResponse($event->getResponse(), $request, $type);
}
return $response;
@ -86,11 +86,11 @@ class HttpKernel implements HttpKernelInterface
protected function handleRaw(Request $request, $type = self::MASTER_REQUEST)
{
// request
$eventArgs = new GetResponseEventArgs($this, $request, $type);
$this->evm->dispatchEvent(Events::onCoreRequest, $eventArgs);
$event = new GetResponseEvent($this, $request, $type);
$this->dispatcher->dispatchEvent(Events::onCoreRequest, $event);
if ($eventArgs->hasResponse()) {
return $this->filterResponse($eventArgs->getResponse(), $request, $type);
if ($event->hasResponse()) {
return $this->filterResponse($event->getResponse(), $request, $type);
}
// load controller
@ -98,9 +98,9 @@ class HttpKernel implements HttpKernelInterface
throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". Maybe you forgot to add the matching route in your routing configuration?', $request->getPathInfo()));
}
$eventArgs = new FilterControllerEventArgs($this, $controller, $request, $type);
$this->evm->dispatchEvent(Events::filterCoreController, $eventArgs);
$controller = $eventArgs->getController();
$event = new FilterControllerEvent($this, $controller, $request, $type);
$this->dispatcher->dispatchEvent(Events::filterCoreController, $event);
$controller = $event->getController();
// controller arguments
$arguments = $this->resolver->getArguments($request, $controller);
@ -110,11 +110,11 @@ class HttpKernel implements HttpKernelInterface
// view
if (!$response instanceof Response) {
$eventArgs = new GetResponseForControllerResultEventArgs($this, $request, $type, $response);
$this->evm->dispatchEvent(Events::onCoreView, $eventArgs);
$event = new GetResponseForControllerResultEvent($this, $request, $type, $response);
$this->dispatcher->dispatchEvent(Events::onCoreView, $event);
if ($eventArgs->hasResponse()) {
$response = $eventArgs->getResponse();
if ($event->hasResponse()) {
$response = $event->getResponse();
}
if (!$response instanceof Response) {
@ -138,11 +138,11 @@ class HttpKernel implements HttpKernelInterface
*/
protected function filterResponse(Response $response, Request $request, $type)
{
$eventArgs = new FilterResponseEventArgs($this, $request, $type, $response);
$event = new FilterResponseEvent($this, $request, $type, $response);
$this->evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
$this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
return $eventArgs->getResponse();
return $event->getResponse();
}
protected function varToString($var)

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\HttpKernel;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\Response;
/**
@ -31,15 +31,15 @@ class ResponseListener
/**
* Filters the Response.
*
* @param FilterResponseEventArgs $eventArgs A FilterResponseEventArgs instance
* @param FilterResponseEvent $event A FilterResponseEvent instance
*/
public function filterCoreResponse(FilterResponseEventArgs $eventArgs)
public function filterCoreResponse(FilterResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $eventArgs->getRequestType()) {
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
$response = $eventArgs->getResponse();
$response = $event->getResponse();
if (null === $response->getCharset()) {
$response->setCharset($this->charset);
@ -49,7 +49,7 @@ class ResponseListener
return;
}
$request = $eventArgs->getRequest();
$request = $event->getRequest();
$format = $request->getRequestFormat();
if ((null !== $format) && $mimeType = $request->getMimeType($format)) {
$response->headers->set('Content-Type', $mimeType);

View File

@ -2,7 +2,7 @@
namespace Symfony\Component\Security\Http\Authentication;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Request;
@ -22,12 +22,12 @@ interface AuthenticationFailureHandlerInterface
* called by authentication listeners inheriting from
* AbstractAuthenticationListener.
*
* @param GetResponseEventArgs $eventArgs the "onCoreSecurity" event, this event always
* @param GetResponseEvent $event the "onCoreSecurity" event, this event always
* has the kernel as target
* @param Request $request
* @param AuthenticationException $exception
*
* @return Response the response to return
*/
function onAuthenticationFailure(GetResponseEventArgs $eventArgs, Request $request, AuthenticationException $exception);
function onAuthenticationFailure(GetResponseEvent $event, Request $request, AuthenticationException $exception);
}

View File

@ -2,7 +2,7 @@
namespace Symfony\Component\Security\Http\Authentication;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Request;
@ -22,12 +22,12 @@ interface AuthenticationSuccessHandlerInterface
* is called by authentication listeners inheriting from
* AbstractAuthenticationListener.
*
* @param GetResponseEventArgs $eventArgs the "onCoreSecurity" event, this event always
* @param GetResponseEvent $event the "onCoreSecurity" event, this event always
* has the kernel as target
* @param Request $request
* @param TokenInterface $token
*
* @return Response the response to return
*/
function onAuthenticationSuccess(GetResponseEventArgs $eventArgs, Request $request, TokenInterface $token);
function onAuthenticationSuccess(GetResponseEvent $event, Request $request, TokenInterface $token);
}

View File

@ -3,7 +3,7 @@
namespace Symfony\Component\Security\Http\Authorization;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ExceptionEventArgs;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
/**
@ -17,11 +17,11 @@ interface AccessDeniedHandlerInterface
/**
* Handles an access denied failure.
*
* @param ExceptionEventArgs $eventArgs
* @param ExceptionEvent $event
* @param Request $request
* @param AccessDeniedException $accessDeniedException
*
* @return Response may return null
*/
function handle(ExceptionEventArgs $eventArgs, Request $request, AccessDeniedException $accessDeniedException);
function handle(ExceptionEvent $event, Request $request, AccessDeniedException $accessDeniedException);
}

View File

@ -11,7 +11,7 @@
namespace Symfony\Component\Security\Http\EntryPoint;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Request;
@ -26,9 +26,9 @@ interface AuthenticationEntryPointInterface
/**
* Starts the authentication scheme.
*
* @param GetResponseEventArgs $eventArgs The "onCoreSecurity" event
* @param GetResponseEvent $event The "onCoreSecurity" event
* @param object $request The request that resulted in an AuthenticationException
* @param AuthenticationException $authException The exception that started the authentication process
*/
function start(GetResponseEventArgs $eventArgs, Request $request, AuthenticationException $authException = null);
function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null);
}

View File

@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
* BasicAuthenticationEntryPoint starts an HTTP Basic authentication.
@ -31,7 +31,7 @@ class BasicAuthenticationEntryPoint implements AuthenticationEntryPointInterface
$this->realmName = $realmName;
}
public function start(GetResponseEventArgs $event, Request $request, AuthenticationException $authException = null)
public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
{
$response = new Response();
$response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', $this->realmName));

View File

@ -17,7 +17,7 @@ use Symfony\Component\Security\Core\Exception\NonceExpiredException;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
* DigestAuthenticationEntryPoint starts an HTTP Digest authentication.
@ -39,7 +39,7 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac
$this->logger = $logger;
}
public function start(GetResponseEventArgs $eventArgs, Request $request, AuthenticationException $authException = null)
public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
{
$expiryTime = microtime(true) + $this->nonceValiditySeconds * 1000;
$signatureValue = md5($expiryTime.':'.$this->key);

View File

@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
* FormAuthenticationEntryPoint starts an authentication via a login form.
@ -44,7 +44,7 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
/**
* {@inheritdoc}
*/
public function start(GetResponseEventArgs $eventArgs, Request $request, AuthenticationException $authException = null)
public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
{
if ($this->useForward) {
return $event->getKernel()->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST);

View File

@ -16,7 +16,7 @@ use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
* RetryAuthenticationEntryPoint redirects URL based on the configured scheme.
@ -36,7 +36,7 @@ class RetryAuthenticationEntryPoint implements AuthenticationEntryPointInterface
$this->httpsPort = $httpsPort;
}
public function start(GetResponseEventArgs $eventArgs, Request $request, AuthenticationException $authException = null)
public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
{
$scheme = $request->isSecure() ? 'http' : 'https';
if ('http' === $scheme && 80 != $this->httpPort) {

View File

@ -12,9 +12,9 @@
namespace Symfony\Component\Security\Http\Event;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\Common\EventArgs;
use Symfony\Component\EventDispatcher\Event;
class InteractiveLoginEventArgs extends EventArgs
class InteractiveLoginEvent extends Event
{
private $request;

View File

@ -13,9 +13,9 @@ namespace Symfony\Component\Security\Http\Event;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Common\EventArgs;
use Symfony\Component\EventDispatcher\Event;
class SwitchUserEventArgs extends EventArgs
class SwitchUserEvent extends Event
{
private $request;

View File

@ -13,9 +13,9 @@ namespace Symfony\Component\Security\Http;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Events;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Firewall uses a FirewallMap to register security listeners for the given
@ -30,7 +30,7 @@ use Doctrine\Common\EventManager;
class Firewall
{
private $map;
private $evm;
private $dispatcher;
private $currentListeners;
/**
@ -38,35 +38,35 @@ class Firewall
*
* @param FirewallMap $map A FirewallMap instance
*/
public function __construct(FirewallMapInterface $map, EventManager $evm)
public function __construct(FirewallMapInterface $map, EventDispatcherInterface $dispatcher)
{
$this->map = $map;
$this->evm = $evm;
$this->dispatcher = $dispatcher;
$this->currentListeners = array();
}
/**
* Handles security.
*
* @param GetResponseEventArgs $eventArgs An GetResponseEventArgs instance
* @param GetResponseEvent $event An GetResponseEvent instance
*/
public function onCoreRequest(GetResponseEventArgs $eventArgs)
public function onCoreRequest(GetResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $eventArgs->getRequestType()) {
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
// register listeners for this firewall
list($listeners, $exception) = $this->map->getListeners($eventArgs->getRequest());
list($listeners, $exception) = $this->map->getListeners($event->getRequest());
if (null !== $exception) {
$exception->register($this->evm);
$exception->register($this->dispatcher);
}
// initiate the listener chain
foreach ($listeners as $listener) {
$response = $listener->handle($eventArgs);
$response = $listener->handle($event);
if ($eventArgs->hasResponse()) {
if ($event->hasResponse()) {
break;
}
}

View File

@ -21,12 +21,12 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Events as KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* The AbstractAuthenticationListener is the preferred base class for all
@ -53,7 +53,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
protected $providerKey;
private $securityContext;
private $sessionStrategy;
private $evm;
private $dispatcher;
private $successHandler;
private $failureHandler;
private $rememberMeServices;
@ -66,7 +66,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
* @param array $options An array of options for the processing of a successful, or failed authentication attempt
* @param LoggerInterface $logger A LoggerInterface instance
*/
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, $providerKey, array $options = array(), AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, LoggerInterface $logger = null, EventManager $evm = null)
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, $providerKey, array $options = array(), AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
{
if (empty($providerKey)) {
throw new \InvalidArgumentException('$providerKey must not be empty.');
@ -89,7 +89,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
'failure_forward' => false,
), $options);
$this->logger = $logger;
$this->evm = $evm;
$this->dispatcher = $dispatcher;
}
/**
@ -107,9 +107,9 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
*
* @param Event $event An Event instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
$request = $eventArgs->getRequest();
$request = $event->getRequest();
if (!$this->requiresAuthentication($request)) {
return;
@ -123,17 +123,17 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
if ($returnValue instanceof TokenInterface) {
$this->sessionStrategy->onAuthentication($request, $returnValue);
$response = $this->onSuccess($eventArgs, $request, $returnValue);
$response = $this->onSuccess($event, $request, $returnValue);
} else if ($returnValue instanceof Response) {
$response = $returnValue;
} else {
throw new \RuntimeException('attemptAuthentication() must either return a Response, an implementation of TokenInterface, or null.');
}
} catch (AuthenticationException $e) {
$response = $this->onFailure($eventArgs, $request, $e);
$response = $this->onFailure($event, $request, $e);
}
$eventArgs->setResponse($response);
$event->setResponse($response);
}
/**
@ -163,7 +163,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
*/
abstract protected function attemptAuthentication(Request $request);
private function onFailure(GetResponseEventArgs $eventArgs, Request $request, AuthenticationException $failed)
private function onFailure(GetResponseEvent $event, Request $request, AuthenticationException $failed)
{
if (null !== $this->logger) {
$this->logger->debug(sprintf('Authentication request failed: %s', $failed->getMessage()));
@ -172,7 +172,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
$this->securityContext->setToken(null);
if (null !== $this->failureHandler) {
return $this->failureHandler->onAuthenticationFailure($eventArgs, $request, $failed);
return $this->failureHandler->onAuthenticationFailure($event, $request, $failed);
}
if (null === $this->options['failure_path']) {
@ -187,7 +187,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
$subRequest = Request::create($this->options['failure_path']);
$subRequest->attributes->set(SecurityContextInterface::AUTHENTICATION_ERROR, $failed);
return $eventArgs->getSubject()->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
return $event->getSubject()->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
}
if (null !== $this->logger) {
@ -199,7 +199,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
return new RedirectResponse(0 !== strpos($this->options['failure_path'], 'http') ? $request->getUriForPath($this->options['failure_path']) : $this->options['failure_path'], 302);
}
private function onSuccess(GetResponseEventArgs $eventArgs, Request $request, TokenInterface $token)
private function onSuccess(GetResponseEvent $event, Request $request, TokenInterface $token)
{
if (null !== $this->logger) {
$this->logger->debug('User has been authenticated successfully');
@ -211,13 +211,13 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
$session->remove(SecurityContextInterface::AUTHENTICATION_ERROR);
$session->remove(SecurityContextInterface::LAST_USERNAME);
if (null !== $this->evm) {
$loginEventArgs = new InteractiveLoginEventArgs($request, $token);
$this->evm->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEventArgs);
if (null !== $this->dispatcher) {
$loginEvent = new InteractiveLoginEvent($request, $token);
$this->dispatcher->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEvent);
}
if (null !== $this->successHandler) {
$response = $this->successHandler->onAuthenticationSuccess($eventArgs, $request, $token);
$response = $this->successHandler->onAuthenticationSuccess($event, $request, $token);
} else {
$path = $this->determineTargetUrl($request);
$response = new RedirectResponse(0 !== strpos($path, 'http') ? $request->getUriForPath($path) : $path, 302);

View File

@ -15,13 +15,13 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Event\InteractiveLoginEventArgs;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\Events;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Events as KernelEvents;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* AbstractPreAuthenticatedListener is the base class for all listener that
@ -36,25 +36,25 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
private $securityContext;
private $authenticationManager;
private $providerKey;
private $evm;
private $dispatcher;
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, LoggerInterface $logger = null, EventManager $evm = null)
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
{
$this->securityContext = $securityContext;
$this->authenticationManager = $authenticationManager;
$this->providerKey = $providerKey;
$this->logger = $logger;
$this->evm = $evm;
$this->dispatcher = $dispatcher;
}
/**
* Handles X509 authentication.
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
$request = $eventArgs->getRequest();
$request = $event->getRequest();
if (null !== $this->logger) {
$this->logger->debug(sprintf('Checking secure context token: %s', $this->securityContext->getToken()));
@ -80,9 +80,9 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
}
$this->securityContext->setToken($token);
if (null !== $this->evm) {
$loginEventArgs = new InteractiveLoginEventArgs($request, $token);
$this->evm->notify(Events::onSecurityInteractiveLogin, $loginEventArgs);
if (null !== $this->dispatcher) {
$loginEvent = new InteractiveLoginEvent($request, $token);
$this->dispatcher->notify(Events::onSecurityInteractiveLogin, $loginEvent);
}
} catch (AuthenticationException $failed) {
$this->securityContext->setToken(null);

View File

@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
use Symfony\Component\Security\Http\AccessMap;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Events;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
@ -46,15 +46,15 @@ class AccessListener implements ListenerInterface
/**
* Handles access authorization.
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
if (null === $token = $this->context->getToken()) {
throw new AuthenticationCredentialsNotFoundException('A Token was not found in the SecurityContext.');
}
$request = $eventArgs->getRequest();
$request = $event->getRequest();
list($attributes, $channel) = $this->map->getPatterns($request);

View File

@ -13,7 +13,7 @@ namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Events;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
@ -39,9 +39,9 @@ class AnonymousAuthenticationListener implements ListenerInterface
/**
* Handles anonymous authentication.
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
if (null !== $this->context->getToken()) {
return;

View File

@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Events;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
@ -51,11 +51,11 @@ class BasicAuthenticationListener implements ListenerInterface
/**
* Handles basic authentication.
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
$request = $eventArgs->getRequest();
$request = $event->getRequest();
if (false === $username = $request->server->get('PHP_AUTH_USER', false)) {
return;

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\Security\Http\AccessMap;
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Events;
/**
@ -39,11 +39,11 @@ class ChannelListener implements ListenerInterface
/**
* Handles channel management.
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
$request = $eventArgs->getRequest();
$request = $event->getRequest();
list($attributes, $channel) = $this->map->getPatterns($request);
@ -52,9 +52,9 @@ class ChannelListener implements ListenerInterface
$this->logger->debug('Redirecting to HTTPS');
}
$response = $this->authenticationEntryPoint->start($eventArgs, $request);
$response = $this->authenticationEntryPoint->start($event, $request);
$eventArgs->setResponse($response);
$event->setResponse($response);
return;
}
@ -64,9 +64,9 @@ class ChannelListener implements ListenerInterface
$this->logger->debug('Redirecting to HTTP');
}
$response = $this->authenticationEntryPoint->start($eventArgs, $request);
$response = $this->authenticationEntryPoint->start($event, $request);
$eventArgs->setResponse($response);
$event->setResponse($response);
}
}
}

View File

@ -14,8 +14,8 @@ namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Events;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@ -23,7 +23,7 @@ use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* ContextListener manages the SecurityContext persistence through a session.
@ -38,7 +38,7 @@ class ContextListener implements ListenerInterface
private $logger;
private $userProviders;
public function __construct(SecurityContext $context, array $userProviders, $contextKey, LoggerInterface $logger = null, EventManager $evm = null)
public function __construct(SecurityContext $context, array $userProviders, $contextKey, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
{
if (empty($contextKey)) {
throw new \InvalidArgumentException('$contextKey must not be empty.');
@ -48,19 +48,19 @@ class ContextListener implements ListenerInterface
$this->userProviders = $userProviders;
$this->contextKey = $contextKey;
if (null !== $evm) {
$evm->connect(Events::onCoreResponse, $this);
if (null !== $dispatcher) {
$dispatcher->connect(Events::onCoreResponse, $this);
}
}
/**
* Reads the SecurityContext from the session.
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
$request = $eventArgs->getRequest();
$request = $event->getRequest();
$session = $request->hasSession() ? $request->getSession() : null;
@ -84,11 +84,11 @@ class ContextListener implements ListenerInterface
/**
* Writes the SecurityContext to the session.
*
* @param FilterResponseEventArgs $eventArgs A FilterResponseEventArgs instance
* @param FilterResponseEvent $event A FilterResponseEvent instance
*/
public function filterCoreResponse(FilterResponseEventArgs $eventArgs)
public function filterCoreResponse(FilterResponseEvent $event)
{
if (HttpKernelInterface::MASTER_REQUEST !== $eventArgs->getRequestType()) {
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
return;
}
@ -104,7 +104,7 @@ class ContextListener implements ListenerInterface
$this->logger->debug('Write SecurityContext in the session');
}
$eventArgs->getRequest()->getSession()->set('_security_'.$this->contextKey, serialize($token));
$event->getRequest()->getSession()->set('_security_'.$this->contextKey, serialize($token));
}
/**

View File

@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Http\EntryPoint\DigestAuthenticationEntryPoint;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Events;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
@ -54,11 +54,11 @@ class DigestAuthenticationListener implements ListenerInterface
/**
* Handles digest authentication.
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
$request = $eventArgs->getRequest();
$request = $event->getRequest();
if (!$header = $request->server->get('PHP_AUTH_DIGEST')) {
return;
@ -79,7 +79,7 @@ class DigestAuthenticationListener implements ListenerInterface
try {
$digestAuth->validateAndDecode($this->authenticationEntryPoint->getKey(), $this->authenticationEntryPoint->getRealmName());
} catch (BadCredentialsException $e) {
$this->fail($eventArgs, $request, $e);
$this->fail($event, $request, $e);
return;
}
@ -93,7 +93,7 @@ class DigestAuthenticationListener implements ListenerInterface
$serverDigestMd5 = $digestAuth->calculateServerDigest($user->getPassword(), $request->getMethod());
} catch (UsernameNotFoundException $notFound) {
$this->fail($eventArgs, $request, new BadCredentialsException(sprintf('Username %s not found.', $digestAuth->getUsername())));
$this->fail($event, $request, new BadCredentialsException(sprintf('Username %s not found.', $digestAuth->getUsername())));
return;
}
@ -103,13 +103,13 @@ class DigestAuthenticationListener implements ListenerInterface
$this->logger->debug(sprintf("Expected response: '%s' but received: '%s'; is AuthenticationDao returning clear text passwords?", $serverDigestMd5, $digestAuth->getResponse()));
}
$this->fail($eventArgs, $request, new BadCredentialsException('Incorrect response'));
$this->fail($event, $request, new BadCredentialsException('Incorrect response'));
return;
}
if ($digestAuth->isNonceExpired()) {
$this->fail($eventArgs, $request, new NonceExpiredException('Nonce has expired/timed out.'));
$this->fail($event, $request, new NonceExpiredException('Nonce has expired/timed out.'));
return;
}
@ -121,7 +121,7 @@ class DigestAuthenticationListener implements ListenerInterface
$this->securityContext->setToken(new UsernamePasswordToken($user, $user->getPassword(), $this->providerKey));
}
private function fail(GetResponseEventArgs $eventArgs, Request $request, AuthenticationException $authException)
private function fail(GetResponseEvent $event, Request $request, AuthenticationException $authException)
{
$this->securityContext->setToken(null);
@ -129,7 +129,7 @@ class DigestAuthenticationListener implements ListenerInterface
$this->logger->debug($authException);
}
$this->authenticationEntryPoint->start($eventArgs, $request, $authException);
$this->authenticationEntryPoint->start($event, $request, $authException);
}
}

View File

@ -24,7 +24,7 @@ use Symfony\Component\Security\Core\Exception\InsufficientAuthenticationExceptio
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Events;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* ExceptionListener catches authentication exception and converts them to
@ -54,22 +54,22 @@ class ExceptionListener
/**
* Registers a onCoreException listener to take care of security exceptions.
*
* @param EventManager $evm An EventManager instance
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
*/
public function register(EventManager $evm)
public function register(EventDispatcherInterface $dispatcher)
{
$evm->connect(Events::onCoreException, $this);
$dispatcher->connect(Events::onCoreException, $this);
}
/**
* Handles security related exceptions.
*
* @param ExceptionEventArgs $event An ExceptionEventArgs instance
* @param ExceptionEvent $event An ExceptionEvent instance
*/
public function onCoreException(ExceptionEventArgs $eventArgs)
public function onCoreException(ExceptionEvent $event)
{
$exception = $eventArgs->getException();
$request = $eventArgs->getRequest();
$exception = $event->getException();
$request = $event->getRequest();
if ($exception instanceof AuthenticationException) {
if (null !== $this->logger) {
@ -77,9 +77,9 @@ class ExceptionListener
}
try {
$response = $this->startAuthentication($eventArgs, $request, $exception);
$response = $this->startAuthentication($event, $request, $exception);
} catch (\Exception $e) {
$eventArgs->set('exception', $e);
$event->set('exception', $e);
return;
}
@ -91,9 +91,9 @@ class ExceptionListener
}
try {
$response = $this->startAuthentication($eventArgs, $request, new InsufficientAuthenticationException('Full authentication is required to access this resource.', $token, 0, $exception));
$response = $this->startAuthentication($event, $request, new InsufficientAuthenticationException('Full authentication is required to access this resource.', $token, 0, $exception));
} catch (\Exception $e) {
$eventArgs->set('exception', $e);
$event->set('exception', $e);
return;
}
@ -104,7 +104,7 @@ class ExceptionListener
try {
if (null !== $this->accessDeniedHandler) {
$response = $this->accessDeniedHandler->handle($eventArgs, $request, $exception);
$response = $this->accessDeniedHandler->handle($event, $request, $exception);
if (!$response instanceof Response) {
return;
@ -117,7 +117,7 @@ class ExceptionListener
$subRequest = Request::create($this->errorPage);
$subRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR, $exception);
$response = $eventArgs->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
$response = $event->getKernel()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
$response->setStatusCode(403);
}
} catch (\Exception $e) {
@ -125,7 +125,7 @@ class ExceptionListener
$this->logger->err(sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()));
}
$eventArgs->setException(new \RuntimeException('Exception thrown when handling an exception.', 0, $e));
$event->setException(new \RuntimeException('Exception thrown when handling an exception.', 0, $e));
return;
}
@ -134,10 +134,10 @@ class ExceptionListener
return;
}
$eventArgs->setResponse($response);
$event->setResponse($response);
}
private function startAuthentication(ExceptionEventArgs $eventArgs, Request $request, AuthenticationException $authException)
private function startAuthentication(ExceptionEvent $event, Request $request, AuthenticationException $authException)
{
$this->context->setToken(null);
@ -154,6 +154,6 @@ class ExceptionListener
$request->getSession()->set('_security.target_path', $request->getUri());
}
return $this->authenticationEntryPoint->start($eventArgs, $request, $authException);
return $this->authenticationEntryPoint->start($event, $request, $authException);
}
}

View File

@ -11,8 +11,8 @@
namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Doctrine\Common\EventManager;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* Interface that must be implemented by firewall listeners
@ -24,7 +24,7 @@ interface ListenerInterface
/**
* This interface must be implemented by firewall listeners.
*
* @param GetResponseEventArgs $eventArgs
* @param GetResponseEvent $event
*/
function onCoreSecurity(GetResponseEventArgs $eventArgs);
function onCoreSecurity(GetResponseEvent $event);
}

View File

@ -17,7 +17,7 @@ use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Kernel\Event\GetResponseEventArgs;
use Symfony\Component\Kernel\Event\GetResponseEvent;
use Symfony\Component\Kernel\Events;
/**
@ -63,18 +63,18 @@ class LogoutListener implements ListenerInterface
/**
* Performs the logout if requested
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
$request = $eventArgs->getRequest();
$request = $event->getRequest();
if ($this->logoutPath !== $request->getPathInfo()) {
return;
}
if (null !== $this->successHandler) {
$response = $this->successHandler->onLogoutSuccess($eventArgs, $request);
$response = $this->successHandler->onLogoutSuccess($event, $request);
if (!$response instanceof Response) {
throw new \RuntimeException('Logout Success Handler did not return a Response.');

View File

@ -4,8 +4,8 @@ namespace Symfony\Component\Security\Http\Firewall;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Events as KernelEvents;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@ -14,9 +14,9 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\CookieTheftException;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEventArgs;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\Events;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/*
* This file is part of the Symfony framework.
@ -38,7 +38,7 @@ class RememberMeListener implements ListenerInterface
private $rememberMeServices;
private $authenticationManager;
private $logger;
private $evm;
private $dispatcher;
/**
* Constructor
@ -48,27 +48,27 @@ class RememberMeListener implements ListenerInterface
* @param AuthenticationManagerInterface $authenticationManager
* @param LoggerInterface $logger
*/
public function __construct(SecurityContext $securityContext, RememberMeServicesInterface $rememberMeServices, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null, EventManager $evm = null)
public function __construct(SecurityContext $securityContext, RememberMeServicesInterface $rememberMeServices, AuthenticationManagerInterface $authenticationManager, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
{
$this->securityContext = $securityContext;
$this->rememberMeServices = $rememberMeServices;
$this->authenticationManager = $authenticationManager;
$this->logger = $logger;
$this->evm = $evm;
$this->dispatcher = $dispatcher;
}
/**
* Handles remember-me cookie based authentication.
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
if (null !== $this->securityContext->getToken()) {
return;
}
$request = $eventArgs->getRequest();
$request = $event->getRequest();
if (null === $token = $this->rememberMeServices->autoLogin($request)) {
return;
}
@ -77,9 +77,9 @@ class RememberMeListener implements ListenerInterface
$token = $this->authenticationManager->authenticate($token);
$this->securityContext->setToken($token);
if (null !== $this->evm) {
$loginEventArgs = new InteractiveLoginEventArgs($request, $token);
$this->evm->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEventArgs);
if (null !== $this->dispatcher) {
$loginEvent = new InteractiveLoginEvent($request, $token);
$this->dispatcher->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEvent);
}
if (null !== $this->logger) {

View File

@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Events;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\HttpFoundation\Response;
@ -26,9 +26,9 @@ use Symfony\Component\Security\Core\Role\SwitchUserRole;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Http\Event\SwitchUserEventArgs;
use Symfony\Component\Security\Http\Event\SwitchUserEvent;
use Symfony\Component\Security\Http\Events;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* SwitchUserListener allows a user to impersonate another one temporarily
@ -46,12 +46,12 @@ class SwitchUserListener implements ListenerInterface
private $usernameParameter;
private $role;
private $logger;
private $evm;
private $dispatcher;
/**
* Constructor.
*/
public function __construct(SecurityContextInterface $securityContext, UserProviderInterface $provider, UserCheckerInterface $userChecker, $providerKey, AccessDecisionManagerInterface $accessDecisionManager, LoggerInterface $logger = null, $usernameParameter = '_switch_user', $role = 'ROLE_ALLOWED_TO_SWITCH', EventManager $evm = null)
public function __construct(SecurityContextInterface $securityContext, UserProviderInterface $provider, UserCheckerInterface $userChecker, $providerKey, AccessDecisionManagerInterface $accessDecisionManager, LoggerInterface $logger = null, $usernameParameter = '_switch_user', $role = 'ROLE_ALLOWED_TO_SWITCH', EventDispatcherInterface $dispatcher = null)
{
if (empty($providerKey)) {
throw new \InvalidArgumentException('$providerKey must not be empty.');
@ -65,17 +65,17 @@ class SwitchUserListener implements ListenerInterface
$this->usernameParameter = $usernameParameter;
$this->role = $role;
$this->logger = $logger;
$this->evm = $evm;
$this->dispatcher = $dispatcher;
}
/**
* Handles digest authentication.
*
* @param GetResponseEventArgs $eventArgs A GetResponseEventArgs instance
* @param GetResponseEvent $event A GetResponseEvent instance
*/
public function onCoreSecurity(GetResponseEventArgs $eventArgs)
public function onCoreSecurity(GetResponseEvent $event)
{
$request = $eventArgs->getRequest();
$request = $event->getRequest();
if (!$request->get($this->usernameParameter)) {
return;
@ -129,9 +129,9 @@ class SwitchUserListener implements ListenerInterface
$token = new UsernamePasswordToken($user, $user->getPassword(), $this->providerKey, $roles);
if (null !== $this->evm) {
$switchEventArgs = new SwitchUserEventArgs($request, $token->getUser());
$this->evm->dispatchEvent(Events::onSecuritySwitchUser, $switchEventArgs);
if (null !== $this->dispatcher) {
$switchEvent = new SwitchUserEvent($request, $token->getUser());
$this->dispatcher->dispatchEvent(Events::onSecuritySwitchUser, $switchEvent);
}
return $token;
@ -150,9 +150,9 @@ class SwitchUserListener implements ListenerInterface
throw new AuthenticationCredentialsNotFoundException(sprintf('Could not find original Token object.'));
}
if (null !== $this->evm) {
$switchEventArgs = new SwitchUserEventArgs($request, $original->getUser());
$this->evm->notify(Events::onSecuritySwitchUser, $switchEventArgs);
if (null !== $this->dispatcher) {
$switchEvent = new SwitchUserEvent($request, $original->getUser());
$this->dispatcher->notify(Events::onSecuritySwitchUser, $switchEvent);
}
return $original;

View File

@ -21,7 +21,7 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterfac
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* UsernamePasswordFormAuthenticationListener is the default implementation of
@ -36,7 +36,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
/**
* {@inheritdoc}
*/
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, $providerKey, array $options = array(), AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, LoggerInterface $logger = null, EventManager $evm = null, CsrfProviderInterface $csrfProvider = null)
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, SessionAuthenticationStrategyInterface $sessionStrategy, $providerKey, array $options = array(), AuthenticationSuccessHandlerInterface $successHandler = null, AuthenticationFailureHandlerInterface $failureHandler = null, LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null, CsrfProviderInterface $csrfProvider = null)
{
parent::__construct($securityContext, $authenticationManager, $sessionStrategy, $providerKey, array_merge(array(
'username_parameter' => '_username',
@ -44,7 +44,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
'csrf_parameter' => '_csrf_token',
'csrf_page_id' => 'form_login',
'post_only' => true,
), $options), $successHandler, $failureHandler, $logger, $evm);
), $options), $successHandler, $failureHandler, $logger, $dispatcher);
$this->csrfProvider = $csrfProvider;
}

View File

@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterfac
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* X509 authentication listener.
@ -28,9 +28,9 @@ class X509AuthenticationListener extends AbstractPreAuthenticatedListener
protected $userKey;
protected $credentialKey;
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, $userKey = 'SSL_CLIENT_S_DN_Email', $credentialKey = 'SSL_CLIENT_S_DN', LoggerInterface $logger = null, EventManager $evm = null)
public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager, $providerKey, $userKey = 'SSL_CLIENT_S_DN_Email', $credentialKey = 'SSL_CLIENT_S_DN', LoggerInterface $logger = null, EventDispatcherInterface $dispatcher = null)
{
parent::__construct($securityContext, $authenticationManager, $providerKey, $logger, $evm);
parent::__construct($securityContext, $authenticationManager, $providerKey, $logger, $dispatcher);
$this->userKey = $userKey;
$this->credentialKey = $credentialKey;

View File

@ -3,7 +3,7 @@
namespace Symfony\Component\Security\Http\Logout;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
/**
* LogoutSuccesshandlerInterface.
@ -21,9 +21,9 @@ interface LogoutSuccessHandlerInterface
/**
* Creates a Response object to send upon a successful logout.
*
* @param GetResponseEventArgs $eventArgs
* @param GetResponseEvent $event
* @param Request $request
* @return Response never null
*/
function onLogoutSuccess(GetResponseEventArgs $eventArgs, Request $request);
function onLogoutSuccess(GetResponseEvent $event, Request $request);
}

View File

@ -14,16 +14,15 @@ namespace Symfony\Tests\Component\HttpKernel\DataCollector;
use Symfony\Component\HttpKernel\DataCollector\EventDataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Debug\TraceableEventManagerInterface;
use Doctrine\Common\EventManager;
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
class EventDataCollectorTest extends \PHPUnit_Framework_TestCase
{
public function testCollect()
{
$c = new EventDataCollector();
$c->setEventManager(new TestEventManager());
$c->setEventDispatcher(new TestEventDispatcher());
$c->collect(new Request(), new Response());
@ -34,7 +33,7 @@ class EventDataCollectorTest extends \PHPUnit_Framework_TestCase
}
class TestEventManager extends EventManager implements TraceableEventManagerInterface
class TestEventDispatcher extends EventDispatcher implements TraceableEventDispatcherInterface
{
function getCalledListeners()
{

View File

@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Debug\ExceptionListener;
use Symfony\Component\HttpKernel\Debug\ErrorException;
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEventArgs;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Tests\Component\HttpKernel\Logger;
@ -44,19 +44,19 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider provider
*/
public function testHandleWithoutLogger($eventArgs, $eventArgs2)
public function testHandleWithoutLogger($event, $event2)
{
//store the current error_log, and set the new one to dev/null
$error_log = ini_get('error_log');
ini_set('error_log', '/dev/null');
$l = new ExceptionListener('foo');
$l->onCoreException($eventArgs);
$l->onCoreException($event);
$this->assertEquals(new Response('foo'), $eventArgs->getResponse());
$this->assertEquals(new Response('foo'), $event->getResponse());
try {
$l->onCoreException($eventArgs2);
$l->onCoreException($event2);
} catch(\Exception $e) {
$this->assertSame('foo', $e->getMessage());
}
@ -68,17 +68,17 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider provider
*/
public function testHandleWithLogger($eventArgs, $eventArgs2)
public function testHandleWithLogger($event, $event2)
{
$logger = new TestLogger();
$l = new ExceptionListener('foo', $logger);
$l->onCoreException($eventArgs);
$l->onCoreException($event);
$this->assertEquals(new Response('foo'), $eventArgs->getResponse());
$this->assertEquals(new Response('foo'), $event->getResponse());
try {
$l->onCoreException($eventArgs2);
$l->onCoreException($event2);
} catch(\Exception $e) {
$this->assertSame('foo', $e->getMessage());
}
@ -91,11 +91,11 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
{
$request = new Request();
$exception = new ErrorException('foo');
$eventArgs = new GetResponseForExceptionEventArgs(new TestKernel(), $request, 'foo', $exception);
$eventArgs2 = new GetResponseForExceptionEventArgs(new TestKernelThatThrowsException(), $request, 'foo', $exception);
$event = new GetResponseForExceptionEvent(new TestKernel(), $request, 'foo', $exception);
$event2 = new GetResponseForExceptionEvent(new TestKernelThatThrowsException(), $request, 'foo', $exception);
return array(
array($eventArgs, $eventArgs2)
array($event, $event2)
);
}

View File

@ -13,54 +13,54 @@ namespace Symfony\Tests\Component\HttpKernel\HttpCache;
use Symfony\Component\HttpKernel\HttpCache\Esi;
use Symfony\Component\HttpKernel\HttpCache\EsiListener;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Events;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
class EsiListenerTest extends \PHPUnit_Framework_TestCase
{
public function testFilterDoesNothingForSubRequests()
{
$evm = new EventManager();
$dispatcher = new EventDispatcher();
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$response = new Response('foo <esi:include src="" />');
$listener = new EsiListener(new Esi());
$evm->addEventListener(Events::filterCoreResponse, $listener);
$eventArgs = new FilterResponseEventArgs($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
$evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
$dispatcher->addEventListener(Events::filterCoreResponse, $listener);
$event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
$dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
$this->assertEquals('', $eventArgs->getResponse()->headers->get('Surrogate-Control'));
$this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
}
public function testFilterWhenThereIsSomeEsiIncludes()
{
$evm = new EventManager();
$dispatcher = new EventDispatcher();
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$response = new Response('foo <esi:include src="" />');
$listener = new EsiListener(new Esi());
$evm->addEventListener(Events::filterCoreResponse, $listener);
$eventArgs = new FilterResponseEventArgs($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
$evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
$dispatcher->addEventListener(Events::filterCoreResponse, $listener);
$event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
$dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
$this->assertEquals('content="ESI/1.0"', $eventArgs->getResponse()->headers->get('Surrogate-Control'));
$this->assertEquals('content="ESI/1.0"', $event->getResponse()->headers->get('Surrogate-Control'));
}
public function testFilterWhenThereIsNoEsiIncludes()
{
$evm = new EventManager();
$dispatcher = new EventDispatcher();
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
$response = new Response('foo');
$listener = new EsiListener(new Esi());
$evm->addEventListener(Events::filterCoreResponse, $listener);
$eventArgs = new FilterResponseEventArgs($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
$evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
$dispatcher->addEventListener(Events::filterCoreResponse, $listener);
$event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
$dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
$this->assertEquals('', $eventArgs->getResponse()->headers->get('Surrogate-Control'));
$this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
}
}

View File

@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
class TestHttpKernel extends HttpKernel implements ControllerResolverInterface
{
@ -36,7 +36,7 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface
$this->called = false;
$this->catch = false;
parent::__construct(new EventManager(), $this);
parent::__construct(new EventDispatcher(), $this);
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false)

View File

@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface
{
@ -39,7 +39,7 @@ class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInt
$this->headers[] = $response['headers'];
}
parent::__construct(new EventManager(), $this);
parent::__construct(new EventDispatcher(), $this);
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false)

View File

@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Events;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
class HttpKernelTest extends \PHPUnit_Framework_TestCase
{
@ -25,7 +25,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
*/
public function testHandleWhenControllerThrowsAnExceptionAndRawIsTrue()
{
$kernel = new HttpKernel(new EventManager(), $this->getResolver(function () { throw new \RuntimeException(); }));
$kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); }));
$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true);
}
@ -35,33 +35,33 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
*/
public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalseAndNoListenerIsRegistered()
{
$kernel = new HttpKernel(new EventManager(), $this->getResolver(function () { throw new \RuntimeException(); }));
$kernel = new HttpKernel(new EventDispatcher(), $this->getResolver(function () { throw new \RuntimeException(); }));
$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false);
}
public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse()
{
$evm = new EventManager();
$evm->addEventListener(Events::onCoreException, function ($eventArgs)
$dispatcher = new EventDispatcher();
$dispatcher->addEventListener(Events::onCoreException, function ($event)
{
$eventArgs->setResponse(new Response($eventArgs->getException()->getMessage()));
$event->setResponse(new Response($event->getException()->getMessage()));
});
$kernel = new HttpKernel($evm, $this->getResolver(function () { throw new \RuntimeException('foo'); }));
$kernel = new HttpKernel($dispatcher, $this->getResolver(function () { throw new \RuntimeException('foo'); }));
$this->assertEquals('foo', $kernel->handle(new Request())->getContent());
}
public function testHandleWhenAListenerReturnsAResponse()
{
$evm = new EventManager();
$evm->addEventListener(Events::onCoreRequest, function ($eventArgs)
$dispatcher = new EventDispatcher();
$dispatcher->addEventListener(Events::onCoreRequest, function ($event)
{
$eventArgs->setResponse(new Response('hello'));
$event->setResponse(new Response('hello'));
});
$kernel = new HttpKernel($evm, $this->getResolver());
$kernel = new HttpKernel($dispatcher, $this->getResolver());
$this->assertEquals('hello', $kernel->handle(new Request())->getContent());
}
@ -71,8 +71,8 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
*/
public function testHandleWhenNoControllerIsFound()
{
$evm = new EventManager();
$kernel = new HttpKernel($evm, $this->getResolver(false));
$dispatcher = new EventDispatcher();
$kernel = new HttpKernel($dispatcher, $this->getResolver(false));
$kernel->handle(new Request());
}
@ -82,8 +82,8 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
*/
public function testHandleWhenNoControllerIsNotACallable()
{
$evm = new EventManager();
$kernel = new HttpKernel($evm, $this->getResolver('foobar'));
$dispatcher = new EventDispatcher();
$kernel = new HttpKernel($dispatcher, $this->getResolver('foobar'));
$kernel->handle(new Request());
}
@ -93,32 +93,32 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
*/
public function testHandleWhenControllerDoesNotReturnAResponse()
{
$evm = new EventManager();
$kernel = new HttpKernel($evm, $this->getResolver(function () { return 'foo'; }));
$dispatcher = new EventDispatcher();
$kernel = new HttpKernel($dispatcher, $this->getResolver(function () { return 'foo'; }));
$kernel->handle(new Request());
}
public function testHandleWhenControllerDoesNotReturnAResponseButAViewIsRegistered()
{
$evm = new EventManager();
$evm->addEventListener(Events::onCoreView, function ($eventArgs)
$dispatcher = new EventDispatcher();
$dispatcher->addEventListener(Events::onCoreView, function ($event)
{
$eventArgs->setResponse(new Response($eventArgs->getControllerResult()));
$event->setResponse(new Response($event->getControllerResult()));
});
$kernel = new HttpKernel($evm, $this->getResolver(function () { return 'foo'; }));
$kernel = new HttpKernel($dispatcher, $this->getResolver(function () { return 'foo'; }));
$this->assertEquals('foo', $kernel->handle(new Request())->getContent());
}
public function testHandleWithAResponseListener()
{
$evm = new EventManager();
$evm->addEventListener(Events::filterCoreResponse, function ($eventArgs)
$dispatcher = new EventDispatcher();
$dispatcher->addEventListener(Events::filterCoreResponse, function ($event)
{
$eventArgs->setResponse(new Response('foo'));
$event->setResponse(new Response('foo'));
});
$kernel = new HttpKernel($evm, $this->getResolver());
$kernel = new HttpKernel($dispatcher, $this->getResolver());
$this->assertEquals('foo', $kernel->handle(new Request())->getContent());
}

View File

@ -15,21 +15,21 @@ use Symfony\Component\HttpKernel\ResponseListener;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Events;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
class ResponseListenerTest extends \PHPUnit_Framework_TestCase
{
private $evm;
private $dispatcher;
private $kernel;
protected function setUp()
{
$this->evm = new EventManager();
$this->dispatcher = new EventDispatcher();
$listener = new ResponseListener('UTF-8');
$this->evm->addEventListener(Events::filterCoreResponse, $listener);
$this->dispatcher->addEventListener(Events::filterCoreResponse, $listener);
$this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
@ -38,10 +38,10 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
{
$response = new Response('foo');
$eventArgs = new FilterResponseEventArgs($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
$this->evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
$event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
$this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
$this->assertEquals('', $eventArgs->getResponse()->headers->get('content-type'));
$this->assertEquals('', $event->getResponse()->headers->get('content-type'));
}
public function testFilterDoesNothingIfContentTypeIsSet()
@ -49,20 +49,20 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
$response = new Response('foo');
$response->headers->set('Content-Type', 'text/plain');
$eventArgs = new FilterResponseEventArgs($this->kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
$this->evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
$event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
$this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
$this->assertEquals('text/plain', $eventArgs->getResponse()->headers->get('content-type'));
$this->assertEquals('text/plain', $event->getResponse()->headers->get('content-type'));
}
public function testFilterDoesNothingIfRequestFormatIsNotDefined()
{
$response = new Response('foo');
$eventArgs = new FilterResponseEventArgs($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
$this->evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
$event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
$this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
$this->assertEquals('', $eventArgs->getResponse()->headers->get('content-type'));
$this->assertEquals('', $event->getResponse()->headers->get('content-type'));
}
public function testFilterSetContentType()
@ -71,9 +71,9 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
$request = Request::create('/');
$request->setRequestFormat('json');
$eventArgs = new FilterResponseEventArgs($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
$this->evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
$event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
$this->dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
$this->assertEquals('application/json', $eventArgs->getResponse()->headers->get('content-type'));
$this->assertEquals('application/json', $event->getResponse()->headers->get('content-type'));
}
}

View File

@ -15,13 +15,13 @@ use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Doctrine\Common\EventManager;
use Symfony\Component\EventDispatcher\EventDispatcher;
class TestHttpKernel extends HttpKernel implements ControllerResolverInterface
{
public function __construct()
{
parent::__construct(new EventManager(), $this);
parent::__construct(new EventDispatcher(), $this);
}
public function getController(Request $request)

View File

@ -135,12 +135,12 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
protected function getGetResponseEvent()
{
return $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEventArgs', array(), array(), '', false);
return $this->getMock('Symfony\Component\HttpKernel\Event\GetResponseEvent', array(), array(), '', false);
}
protected function getFilterResponseEvent()
{
return $this->getMock('Symfony\Component\HttpKernel\Event\FilterResponseEventArgs', array(), array(), '', false);
return $this->getMock('Symfony\Component\HttpKernel\Event\FilterResponseEvent', array(), array(), '', false);
}
protected function getListener()