From 06c682b4fb8b68606d461db431e1f1a2d3671cb4 Mon Sep 17 00:00:00 2001 From: Bernhard Schussek Date: Sun, 13 Mar 2011 19:16:56 +0100 Subject: [PATCH] Switched from Doctrine's EventManager implementation to the EventManager clone in Symfony2 (now called EventDispatcher again) --- .../CacheWarmer/AssetWriterCacheWarmer.php | 12 ++-- .../AsseticBundle/Command/DumpCommand.php | 7 +-- .../{WriteEventArgs.php => WriteEvent.php} | 4 +- .../Resources/config/asset_writer.xml | 2 +- .../AssetWriterCacheWarmerTest.php | 12 ++-- .../DoctrineBundle/ConnectionFactory.php | 2 +- ....php => ContainerAwareEventDispatcher.php} | 10 ++-- .../Debug/TraceableEventManager.php | 16 +++--- .../Compiler/RegisterKernelListenersPass.php | 4 +- .../FrameworkExtension.php | 25 +++++---- .../HttpFoundation/SessionListener.php | 10 ++-- .../Bundle/FrameworkBundle/HttpKernel.php | 6 +- .../Profiler/ProfilerListener.php | 20 +++---- .../FrameworkBundle/RequestListener.php | 8 +-- .../Resources/config/collectors.xml | 4 +- .../Resources/config/debug.xml | 4 +- .../Resources/config/services.xml | 6 +- .../HttpFoundation/SessionListenerTest.php | 8 +-- .../FrameworkBundle/Tests/HttpKernelTest.php | 10 ++-- .../Resources/config/security.xml | 2 +- .../SecurityBundle/ResponseListener.php | 8 +-- .../WebDebugToolbarListener.php | 10 ++-- .../EventDispatcher/EventDispatcher.php | 2 +- .../EventDispatcherInterface.php | 2 +- .../EventSubscriberInterface.php | 2 +- .../DataCollector/EventDataCollector.php | 20 +++---- .../DataCollector/LoggerDataCollector.php | 2 +- .../HttpKernel/Debug/ExceptionListener.php | 12 ++-- ... => TraceableEventDispatcherInterface.php} | 2 +- ...ventArgs.php => FilterControllerEvent.php} | 2 +- ...eEventArgs.php => FilterResponseEvent.php} | 2 +- ...onseEventArgs.php => GetResponseEvent.php} | 2 +- ...> GetResponseForControllerResultEvent.php} | 2 +- ...s.php => GetResponseForExceptionEvent.php} | 2 +- .../{KernelEventArgs.php => KernelEvent.php} | 4 +- .../HttpKernel/HttpCache/EsiListener.php | 10 ++-- .../Component/HttpKernel/HttpKernel.php | 56 +++++++++---------- .../Component/HttpKernel/ResponseListener.php | 12 ++-- .../AuthenticationFailureHandlerInterface.php | 6 +- .../AuthenticationSuccessHandlerInterface.php | 6 +- .../AccessDeniedHandlerInterface.php | 6 +- .../AuthenticationEntryPointInterface.php | 6 +- .../BasicAuthenticationEntryPoint.php | 4 +- .../DigestAuthenticationEntryPoint.php | 4 +- .../FormAuthenticationEntryPoint.php | 4 +- .../RetryAuthenticationEntryPoint.php | 4 +- ...ventArgs.php => InteractiveLoginEvent.php} | 4 +- ...hUserEventArgs.php => SwitchUserEvent.php} | 4 +- .../Component/Security/Http/Firewall.php | 24 ++++---- .../AbstractAuthenticationListener.php | 36 ++++++------ .../AbstractPreAuthenticatedListener.php | 24 ++++---- .../Security/Http/Firewall/AccessListener.php | 8 +-- .../AnonymousAuthenticationListener.php | 6 +- .../Firewall/BasicAuthenticationListener.php | 8 +-- .../Http/Firewall/ChannelListener.php | 16 +++--- .../Http/Firewall/ContextListener.php | 26 ++++----- .../Firewall/DigestAuthenticationListener.php | 20 +++---- .../Http/Firewall/ExceptionListener.php | 36 ++++++------ .../Http/Firewall/ListenerInterface.php | 8 +-- .../Security/Http/Firewall/LogoutListener.php | 10 ++-- .../Http/Firewall/RememberMeListener.php | 26 ++++----- .../Http/Firewall/SwitchUserListener.php | 30 +++++----- ...namePasswordFormAuthenticationListener.php | 6 +- .../Firewall/X509AuthenticationListener.php | 6 +- .../Logout/LogoutSuccessHandlerInterface.php | 6 +- .../DataCollector/EventDataCollectorTest.php | 9 ++- .../Debug/ExceptionListenerTest.php | 24 ++++---- .../HttpKernel/HttpCache/EsiListenerTest.php | 34 +++++------ .../HttpKernel/HttpCache/TestHttpKernel.php | 4 +- .../HttpCache/TestMultipleHttpKernel.php | 4 +- .../Component/HttpKernel/HttpKernelTest.php | 50 ++++++++--------- .../HttpKernel/ResponseListenerTest.php | 34 +++++------ .../Component/HttpKernel/TestHttpKernel.php | 4 +- .../Http/Firewall/RememberMeListenerTest.php | 4 +- 74 files changed, 417 insertions(+), 418 deletions(-) rename src/Symfony/Bundle/AsseticBundle/Event/{WriteEventArgs.php => WriteEvent.php} (88%) rename src/Symfony/Bundle/FrameworkBundle/{ContainerAwareEventManager.php => ContainerAwareEventDispatcher.php} (91%) rename src/Symfony/Component/HttpKernel/Debug/{TraceableEventManagerInterface.php => TraceableEventDispatcherInterface.php} (93%) rename src/Symfony/Component/HttpKernel/Event/{FilterControllerEventArgs.php => FilterControllerEvent.php} (96%) rename src/Symfony/Component/HttpKernel/Event/{FilterResponseEventArgs.php => FilterResponseEvent.php} (94%) rename src/Symfony/Component/HttpKernel/Event/{GetResponseEventArgs.php => GetResponseEvent.php} (93%) rename src/Symfony/Component/HttpKernel/Event/{GetResponseForControllerResultEventArgs.php => GetResponseForControllerResultEvent.php} (91%) rename src/Symfony/Component/HttpKernel/Event/{GetResponseForExceptionEventArgs.php => GetResponseForExceptionEvent.php} (92%) rename src/Symfony/Component/HttpKernel/Event/{KernelEventArgs.php => KernelEvent.php} (92%) rename src/Symfony/Component/Security/Http/Event/{InteractiveLoginEventArgs.php => InteractiveLoginEvent.php} (89%) rename src/Symfony/Component/Security/Http/Event/{SwitchUserEventArgs.php => SwitchUserEvent.php} (90%) diff --git a/src/Symfony/Bundle/AsseticBundle/CacheWarmer/AssetWriterCacheWarmer.php b/src/Symfony/Bundle/AsseticBundle/CacheWarmer/AssetWriterCacheWarmer.php index e272db757a..7ee4b00217 100644 --- a/src/Symfony/Bundle/AsseticBundle/CacheWarmer/AssetWriterCacheWarmer.php +++ b/src/Symfony/Bundle/AsseticBundle/CacheWarmer/AssetWriterCacheWarmer.php @@ -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); } diff --git a/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php b/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php index b685d0d3e8..62e74e414c 100644 --- a/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php +++ b/src/Symfony/Bundle/AsseticBundle/Command/DumpCommand.php @@ -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')); diff --git a/src/Symfony/Bundle/AsseticBundle/Event/WriteEventArgs.php b/src/Symfony/Bundle/AsseticBundle/Event/WriteEvent.php similarity index 88% rename from src/Symfony/Bundle/AsseticBundle/Event/WriteEventArgs.php rename to src/Symfony/Bundle/AsseticBundle/Event/WriteEvent.php index b2e9c28bee..7d0be28599 100644 --- a/src/Symfony/Bundle/AsseticBundle/Event/WriteEventArgs.php +++ b/src/Symfony/Bundle/AsseticBundle/Event/WriteEvent.php @@ -11,12 +11,12 @@ namespace Symfony\Bundle\AsseticBundle\Event; -use Doctrine\Common\EventArgs; +use Symfony\Component\EventDispatcher\Event; /** * @author Bernhard Schussek */ -class WriteEventArgs extends EventArgs +class WriteEvent extends Event { private $targetPath; diff --git a/src/Symfony/Bundle/AsseticBundle/Resources/config/asset_writer.xml b/src/Symfony/Bundle/AsseticBundle/Resources/config/asset_writer.xml index e24e1245b7..54dbb83bc9 100644 --- a/src/Symfony/Bundle/AsseticBundle/Resources/config/asset_writer.xml +++ b/src/Symfony/Bundle/AsseticBundle/Resources/config/asset_writer.xml @@ -14,7 +14,7 @@ - + %assetic.write_to% diff --git a/src/Symfony/Bundle/AsseticBundle/Tests/CacheWarmer/AssetWriterCacheWarmerTest.php b/src/Symfony/Bundle/AsseticBundle/Tests/CacheWarmer/AssetWriterCacheWarmerTest.php index 8fc2e174a8..2bd7b6a218 100644 --- a/src/Symfony/Bundle/AsseticBundle/Tests/CacheWarmer/AssetWriterCacheWarmerTest.php +++ b/src/Symfony/Bundle/AsseticBundle/Tests/CacheWarmer/AssetWriterCacheWarmerTest.php @@ -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'); } } diff --git a/src/Symfony/Bundle/DoctrineBundle/ConnectionFactory.php b/src/Symfony/Bundle/DoctrineBundle/ConnectionFactory.php index 6f265f405c..2f485d1b7f 100644 --- a/src/Symfony/Bundle/DoctrineBundle/ConnectionFactory.php +++ b/src/Symfony/Bundle/DoctrineBundle/ConnectionFactory.php @@ -36,7 +36,7 @@ class ConnectionFactory /** * Create a connection by name. - * + * * @param string $connectionName * @return Doctrine\DBAL\Connection */ diff --git a/src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventManager.php b/src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventDispatcher.php similarity index 91% rename from src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventManager.php rename to src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventDispatcher.php index 58c61c4cbb..453a40dee9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventManager.php +++ b/src/Symfony/Bundle/FrameworkBundle/ContainerAwareEventDispatcher.php @@ -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 * @author Bernhard Schussek */ -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); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventManager.php b/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventManager.php index ae8d79e319..f663e786b4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventManager.php +++ b/src/Symfony/Bundle/FrameworkBundle/Debug/TraceableEventManager.php @@ -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 */ -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); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php index 7e65aabcca..45ecf5a388 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php @@ -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) { diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 9868c44b59..1a1a3c3a46 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -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', )); } diff --git a/src/Symfony/Bundle/FrameworkBundle/HttpFoundation/SessionListener.php b/src/Symfony/Bundle/FrameworkBundle/HttpFoundation/SessionListener.php index f4e484e124..d373eb77c4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/HttpFoundation/SessionListener.php +++ b/src/Symfony/Bundle/FrameworkBundle/HttpFoundation/SessionListener.php @@ -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(); } diff --git a/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php b/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php index 7b98564ea1..51edce231f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php +++ b/src/Symfony/Bundle/FrameworkBundle/HttpKernel.php @@ -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; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Profiler/ProfilerListener.php b/src/Symfony/Bundle/FrameworkBundle/Profiler/ProfilerListener.php index bb3dc5a70f..adb8c7a01b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Profiler/ProfilerListener.php +++ b/src/Symfony/Bundle/FrameworkBundle/Profiler/ProfilerListener.php @@ -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; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/RequestListener.php b/src/Symfony/Bundle/FrameworkBundle/RequestListener.php index a9d3c443cb..9d50c32065 100644 --- a/src/Symfony/Bundle/FrameworkBundle/RequestListener.php +++ b/src/Symfony/Bundle/FrameworkBundle/RequestListener.php @@ -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); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml index eb878d28d1..c05564b3c5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml @@ -30,8 +30,8 @@ - - + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml index c0e77666eb..c1fefe3eaa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml @@ -5,11 +5,11 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - Symfony\Bundle\FrameworkBundle\Debug\TraceableEventManager + Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml index 56a0e26fdc..3a1f259b44 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml @@ -5,7 +5,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - Symfony\Bundle\FrameworkBundle\ContainerAwareEventManager + Symfony\Bundle\FrameworkBundle\ContainerAwareEventDispatcher Symfony\Bundle\FrameworkBundle\HttpKernel Symfony\Component\HttpKernel\Debug\ErrorHandler null @@ -16,7 +16,7 @@ - + @@ -25,7 +25,7 @@ - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/HttpFoundation/SessionListenerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/HttpFoundation/SessionListenerTest.php index c106968805..8ee4812dbd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/HttpFoundation/SessionListenerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/HttpFoundation/SessionListenerTest.php @@ -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() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/HttpKernelTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/HttpKernelTest.php index 5d6952e1d4..9942684384 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/HttpKernelTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/HttpKernelTest.php @@ -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) { diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml index 07aa363853..823b635059 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml @@ -108,7 +108,7 @@ - + diff --git a/src/Symfony/Bundle/SecurityBundle/ResponseListener.php b/src/Symfony/Bundle/SecurityBundle/ResponseListener.php index b02de90acb..352bc2f04a 100644 --- a/src/Symfony/Bundle/SecurityBundle/ResponseListener.php +++ b/src/Symfony/Bundle/SecurityBundle/ResponseListener.php @@ -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)); diff --git a/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php b/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php index 02e7c219b6..a8e9166153 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php +++ b/src/Symfony/Bundle/WebProfilerBundle/WebDebugToolbarListener.php @@ -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 diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index ad29a183f7..1c08153b45 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -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. * diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php index 9ff7eab3c4..e5435e3d6a 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php @@ -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. * diff --git a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php index f2e7d7e632..40ec069b41 100644 --- a/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php +++ b/src/Symfony/Component/EventDispatcher/EventSubscriberInterface.php @@ -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. * diff --git a/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php index 5de05170d3..5b5d762213 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php @@ -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() { diff --git a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php index fb2bb829a9..df6c234697 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php @@ -48,7 +48,7 @@ class LoggerDataCollector extends DataCollector * * @return array An array of called events * - * @see TraceableEventManagerInterface + * @see TraceableEventDispatcherInterface */ public function countErrors() { diff --git a/src/Symfony/Component/HttpKernel/Debug/ExceptionListener.php b/src/Symfony/Component/HttpKernel/Debug/ExceptionListener.php index 33917e095f..d2e5fe52ee 100644 --- a/src/Symfony/Component/HttpKernel/Debug/ExceptionListener.php +++ b/src/Symfony/Component/HttpKernel/Debug/ExceptionListener.php @@ -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; } diff --git a/src/Symfony/Component/HttpKernel/Debug/TraceableEventManagerInterface.php b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcherInterface.php similarity index 93% rename from src/Symfony/Component/HttpKernel/Debug/TraceableEventManagerInterface.php rename to src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcherInterface.php index 1ea7edb46c..622acd652a 100644 --- a/src/Symfony/Component/HttpKernel/Debug/TraceableEventManagerInterface.php +++ b/src/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcherInterface.php @@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Debug; /** * @author Fabien Potencier */ -interface TraceableEventManagerInterface +interface TraceableEventDispatcherInterface { /** * Gets the called listeners. diff --git a/src/Symfony/Component/HttpKernel/Event/FilterControllerEventArgs.php b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php similarity index 96% rename from src/Symfony/Component/HttpKernel/Event/FilterControllerEventArgs.php rename to src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php index a4ac0d1d1d..0f0f5725f2 100644 --- a/src/Symfony/Component/HttpKernel/Event/FilterControllerEventArgs.php +++ b/src/Symfony/Component/HttpKernel/Event/FilterControllerEvent.php @@ -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; diff --git a/src/Symfony/Component/HttpKernel/Event/FilterResponseEventArgs.php b/src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php similarity index 94% rename from src/Symfony/Component/HttpKernel/Event/FilterResponseEventArgs.php rename to src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php index 92b48990af..bbca8822bb 100644 --- a/src/Symfony/Component/HttpKernel/Event/FilterResponseEventArgs.php +++ b/src/Symfony/Component/HttpKernel/Event/FilterResponseEvent.php @@ -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; diff --git a/src/Symfony/Component/HttpKernel/Event/GetResponseEventArgs.php b/src/Symfony/Component/HttpKernel/Event/GetResponseEvent.php similarity index 93% rename from src/Symfony/Component/HttpKernel/Event/GetResponseEventArgs.php rename to src/Symfony/Component/HttpKernel/Event/GetResponseEvent.php index a8b109fc29..3d4be5ccb2 100644 --- a/src/Symfony/Component/HttpKernel/Event/GetResponseEventArgs.php +++ b/src/Symfony/Component/HttpKernel/Event/GetResponseEvent.php @@ -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; diff --git a/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEventArgs.php b/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php similarity index 91% rename from src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEventArgs.php rename to src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php index b55ab6234c..18d23e7aec 100644 --- a/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEventArgs.php +++ b/src/Symfony/Component/HttpKernel/Event/GetResponseForControllerResultEvent.php @@ -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; diff --git a/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEventArgs.php b/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php similarity index 92% rename from src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEventArgs.php rename to src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php index fb58e23205..a65cb6f6dc 100644 --- a/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEventArgs.php +++ b/src/Symfony/Component/HttpKernel/Event/GetResponseForExceptionEvent.php @@ -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; diff --git a/src/Symfony/Component/HttpKernel/Event/KernelEventArgs.php b/src/Symfony/Component/HttpKernel/Event/KernelEvent.php similarity index 92% rename from src/Symfony/Component/HttpKernel/Event/KernelEventArgs.php rename to src/Symfony/Component/HttpKernel/Event/KernelEvent.php index 124109fb4b..4b99dee174 100644 --- a/src/Symfony/Component/HttpKernel/Event/KernelEventArgs.php +++ b/src/Symfony/Component/HttpKernel/Event/KernelEvent.php @@ -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; diff --git a/src/Symfony/Component/HttpKernel/HttpCache/EsiListener.php b/src/Symfony/Component/HttpKernel/HttpCache/EsiListener.php index f1d62700f2..fdb989ffe6 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/EsiListener.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/EsiListener.php @@ -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()); } } diff --git a/src/Symfony/Component/HttpKernel/HttpKernel.php b/src/Symfony/Component/HttpKernel/HttpKernel.php index 47bfdfb515..b93e355eb1 100644 --- a/src/Symfony/Component/HttpKernel/HttpKernel.php +++ b/src/Symfony/Component/HttpKernel/HttpKernel.php @@ -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) diff --git a/src/Symfony/Component/HttpKernel/ResponseListener.php b/src/Symfony/Component/HttpKernel/ResponseListener.php index 1b9c1e32d8..01500327a0 100644 --- a/src/Symfony/Component/HttpKernel/ResponseListener.php +++ b/src/Symfony/Component/HttpKernel/ResponseListener.php @@ -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); diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php index b35c232f0c..e2d8eb260b 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationFailureHandlerInterface.php @@ -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); } \ No newline at end of file diff --git a/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php b/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php index 30b5e2611a..d7f8488ebf 100644 --- a/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php +++ b/src/Symfony/Component/Security/Http/Authentication/AuthenticationSuccessHandlerInterface.php @@ -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); } \ No newline at end of file diff --git a/src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php b/src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php index b2fb9eec2d..8474fce1ad 100644 --- a/src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php +++ b/src/Symfony/Component/Security/Http/Authorization/AccessDeniedHandlerInterface.php @@ -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); } \ No newline at end of file diff --git a/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php b/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php index 7d75cbc851..0cf6240d4a 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/AuthenticationEntryPointInterface.php @@ -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); } diff --git a/src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php b/src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php index 984fbecb18..8ac0f648ee 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/BasicAuthenticationEntryPoint.php @@ -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)); diff --git a/src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php b/src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php index 578a3e8d14..81f99b17d2 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/DigestAuthenticationEntryPoint.php @@ -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); diff --git a/src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php b/src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php index f45f9ea0b9..899de47272 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/FormAuthenticationEntryPoint.php @@ -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); diff --git a/src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php b/src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php index 1fb6cc17f7..5439f19eab 100644 --- a/src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php +++ b/src/Symfony/Component/Security/Http/EntryPoint/RetryAuthenticationEntryPoint.php @@ -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) { diff --git a/src/Symfony/Component/Security/Http/Event/InteractiveLoginEventArgs.php b/src/Symfony/Component/Security/Http/Event/InteractiveLoginEvent.php similarity index 89% rename from src/Symfony/Component/Security/Http/Event/InteractiveLoginEventArgs.php rename to src/Symfony/Component/Security/Http/Event/InteractiveLoginEvent.php index 7ca4f4e1a4..1265fe2303 100644 --- a/src/Symfony/Component/Security/Http/Event/InteractiveLoginEventArgs.php +++ b/src/Symfony/Component/Security/Http/Event/InteractiveLoginEvent.php @@ -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; diff --git a/src/Symfony/Component/Security/Http/Event/SwitchUserEventArgs.php b/src/Symfony/Component/Security/Http/Event/SwitchUserEvent.php similarity index 90% rename from src/Symfony/Component/Security/Http/Event/SwitchUserEventArgs.php rename to src/Symfony/Component/Security/Http/Event/SwitchUserEvent.php index c88a500e91..ed293cc1cb 100644 --- a/src/Symfony/Component/Security/Http/Event/SwitchUserEventArgs.php +++ b/src/Symfony/Component/Security/Http/Event/SwitchUserEvent.php @@ -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; diff --git a/src/Symfony/Component/Security/Http/Firewall.php b/src/Symfony/Component/Security/Http/Firewall.php index bff88b9e2c..7bdda2a353 100644 --- a/src/Symfony/Component/Security/Http/Firewall.php +++ b/src/Symfony/Component/Security/Http/Firewall.php @@ -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; } } diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php index f00d5e883e..d045b7b9d7 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractAuthenticationListener.php @@ -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); diff --git a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php index 0177ab7e74..eddb079aaf 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AbstractPreAuthenticatedListener.php @@ -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); diff --git a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php index acbb255b31..02c5e71f3b 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php @@ -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); diff --git a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php index bbdef5d570..26d6464d63 100644 --- a/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/AnonymousAuthenticationListener.php @@ -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; diff --git a/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php index 87d10b8754..002e292712 100644 --- a/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/BasicAuthenticationListener.php @@ -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; diff --git a/src/Symfony/Component/Security/Http/Firewall/ChannelListener.php b/src/Symfony/Component/Security/Http/Firewall/ChannelListener.php index e2b342346a..4abe7b755d 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ChannelListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ChannelListener.php @@ -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); } } } diff --git a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php index 72dab1e0a5..332ae5da34 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ContextListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ContextListener.php @@ -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)); } /** diff --git a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php index 70b32beef4..f2f925fb27 100644 --- a/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/DigestAuthenticationListener.php @@ -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); } } diff --git a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php index e88b84f64c..153aec8ec2 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/ExceptionListener.php @@ -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); } } diff --git a/src/Symfony/Component/Security/Http/Firewall/ListenerInterface.php b/src/Symfony/Component/Security/Http/Firewall/ListenerInterface.php index bfc7478d4d..e451103930 100644 --- a/src/Symfony/Component/Security/Http/Firewall/ListenerInterface.php +++ b/src/Symfony/Component/Security/Http/Firewall/ListenerInterface.php @@ -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); } \ No newline at end of file diff --git a/src/Symfony/Component/Security/Http/Firewall/LogoutListener.php b/src/Symfony/Component/Security/Http/Firewall/LogoutListener.php index d2b18cfa1d..18b37f3e92 100644 --- a/src/Symfony/Component/Security/Http/Firewall/LogoutListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/LogoutListener.php @@ -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.'); diff --git a/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php b/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php index af5fc837a3..0706410f56 100644 --- a/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/RememberMeListener.php @@ -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) { diff --git a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php index 11671efc69..6c89a54beb 100644 --- a/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/SwitchUserListener.php @@ -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; diff --git a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php index 7f60daa5d6..5a84391d5b 100644 --- a/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/UsernamePasswordFormAuthenticationListener.php @@ -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; } diff --git a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php index 509f5419c0..831ca0281b 100644 --- a/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php +++ b/src/Symfony/Component/Security/Http/Firewall/X509AuthenticationListener.php @@ -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; diff --git a/src/Symfony/Component/Security/Http/Logout/LogoutSuccessHandlerInterface.php b/src/Symfony/Component/Security/Http/Logout/LogoutSuccessHandlerInterface.php index 933825676c..21dbb818ff 100644 --- a/src/Symfony/Component/Security/Http/Logout/LogoutSuccessHandlerInterface.php +++ b/src/Symfony/Component/Security/Http/Logout/LogoutSuccessHandlerInterface.php @@ -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); } \ No newline at end of file diff --git a/tests/Symfony/Tests/Component/HttpKernel/DataCollector/EventDataCollectorTest.php b/tests/Symfony/Tests/Component/HttpKernel/DataCollector/EventDataCollectorTest.php index 07db8d4780..2841f12784 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/DataCollector/EventDataCollectorTest.php +++ b/tests/Symfony/Tests/Component/HttpKernel/DataCollector/EventDataCollectorTest.php @@ -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() { diff --git a/tests/Symfony/Tests/Component/HttpKernel/Debug/ExceptionListenerTest.php b/tests/Symfony/Tests/Component/HttpKernel/Debug/ExceptionListenerTest.php index 0a5f77993f..c07212f7b5 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/Debug/ExceptionListenerTest.php +++ b/tests/Symfony/Tests/Component/HttpKernel/Debug/ExceptionListenerTest.php @@ -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) ); } diff --git a/tests/Symfony/Tests/Component/HttpKernel/HttpCache/EsiListenerTest.php b/tests/Symfony/Tests/Component/HttpKernel/HttpCache/EsiListenerTest.php index 32e9a8c5ff..a8f942c666 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/HttpCache/EsiListenerTest.php +++ b/tests/Symfony/Tests/Component/HttpKernel/HttpCache/EsiListenerTest.php @@ -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 '); $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 '); $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')); } } diff --git a/tests/Symfony/Tests/Component/HttpKernel/HttpCache/TestHttpKernel.php b/tests/Symfony/Tests/Component/HttpKernel/HttpCache/TestHttpKernel.php index dbcc64ca36..cb14f94f29 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/HttpCache/TestHttpKernel.php +++ b/tests/Symfony/Tests/Component/HttpKernel/HttpCache/TestHttpKernel.php @@ -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) diff --git a/tests/Symfony/Tests/Component/HttpKernel/HttpCache/TestMultipleHttpKernel.php b/tests/Symfony/Tests/Component/HttpKernel/HttpCache/TestMultipleHttpKernel.php index c9d5910a39..5b6e0f8428 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/HttpCache/TestMultipleHttpKernel.php +++ b/tests/Symfony/Tests/Component/HttpKernel/HttpCache/TestMultipleHttpKernel.php @@ -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) diff --git a/tests/Symfony/Tests/Component/HttpKernel/HttpKernelTest.php b/tests/Symfony/Tests/Component/HttpKernel/HttpKernelTest.php index 4ef592ac3e..b4b60409e1 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/HttpKernelTest.php +++ b/tests/Symfony/Tests/Component/HttpKernel/HttpKernelTest.php @@ -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()); } diff --git a/tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php b/tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php index 91107cbee2..9da2399c57 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php +++ b/tests/Symfony/Tests/Component/HttpKernel/ResponseListenerTest.php @@ -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')); } } diff --git a/tests/Symfony/Tests/Component/HttpKernel/TestHttpKernel.php b/tests/Symfony/Tests/Component/HttpKernel/TestHttpKernel.php index e56bc7bddb..35eda847da 100644 --- a/tests/Symfony/Tests/Component/HttpKernel/TestHttpKernel.php +++ b/tests/Symfony/Tests/Component/HttpKernel/TestHttpKernel.php @@ -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) diff --git a/tests/Symfony/Tests/Component/Security/Http/Firewall/RememberMeListenerTest.php b/tests/Symfony/Tests/Component/Security/Http/Firewall/RememberMeListenerTest.php index 3325d45751..1505d2d2e4 100644 --- a/tests/Symfony/Tests/Component/Security/Http/Firewall/RememberMeListenerTest.php +++ b/tests/Symfony/Tests/Component/Security/Http/Firewall/RememberMeListenerTest.php @@ -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()