Switched from Doctrine's EventManager implementation to the EventManager clone in Symfony2 (now called EventDispatcher again)
This commit is contained in:
parent
699e046b4f
commit
06c682b4fb
@ -14,27 +14,27 @@ namespace Symfony\Bundle\AsseticBundle\CacheWarmer;
|
|||||||
use Assetic\AssetManager;
|
use Assetic\AssetManager;
|
||||||
use Assetic\AssetWriter;
|
use Assetic\AssetWriter;
|
||||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer;
|
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer;
|
||||||
use Symfony\Bundle\AsseticBundle\Event\WriteEventArgs;
|
use Symfony\Bundle\AsseticBundle\Event\WriteEvent;
|
||||||
use Symfony\Bundle\AsseticBundle\Events;
|
use Symfony\Bundle\AsseticBundle\Events;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
class AssetWriterCacheWarmer extends CacheWarmer
|
class AssetWriterCacheWarmer extends CacheWarmer
|
||||||
{
|
{
|
||||||
protected $am;
|
protected $am;
|
||||||
protected $writer;
|
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->am = $am;
|
||||||
$this->writer = $writer;
|
$this->writer = $writer;
|
||||||
$this->evm = $evm;
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function warmUp($cacheDir)
|
public function warmUp($cacheDir)
|
||||||
{
|
{
|
||||||
// notify an event so custom stream wrappers can be registered lazily
|
// 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);
|
$this->writer->writeManagerAssets($this->am);
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,12 @@ namespace Symfony\Bundle\AsseticBundle\Command;
|
|||||||
use Assetic\Asset\AssetInterface;
|
use Assetic\Asset\AssetInterface;
|
||||||
use Assetic\Factory\LazyAssetManager;
|
use Assetic\Factory\LazyAssetManager;
|
||||||
use Symfony\Bundle\FrameworkBundle\Command\Command;
|
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\Bundle\AsseticBundle\Events;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Doctrine\Common\EventManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dumps assets to the filesystem.
|
* Dumps assets to the filesystem.
|
||||||
@ -48,8 +47,8 @@ class DumpCommand extends Command
|
|||||||
$am = $this->container->get('assetic.asset_manager');
|
$am = $this->container->get('assetic.asset_manager');
|
||||||
|
|
||||||
// notify an event so custom stream wrappers can be registered lazily
|
// notify an event so custom stream wrappers can be registered lazily
|
||||||
$eventArgs = new WriteEventArgs($basePath);
|
$event = new WriteEvent($basePath);
|
||||||
$this->container->get('event_manager')->dispatchEvent(Events::onAsseticWrite, $writeEventArgs);
|
$this->container->get('event_dispatcher')->dispatchEvent(Events::onAsseticWrite, $writeEvent);
|
||||||
|
|
||||||
if ($input->getOption('watch')) {
|
if ($input->getOption('watch')) {
|
||||||
return $this->watch($am, $basePath, $output, $this->container->getParameter('kernel.debug'));
|
return $this->watch($am, $basePath, $output, $this->container->getParameter('kernel.debug'));
|
||||||
|
@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\AsseticBundle\Event;
|
namespace Symfony\Bundle\AsseticBundle\Event;
|
||||||
|
|
||||||
use Doctrine\Common\EventArgs;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bernhard Schussek <bernhard.schussek@symfony-project.com>
|
* @author Bernhard Schussek <bernhard.schussek@symfony-project.com>
|
||||||
*/
|
*/
|
||||||
class WriteEventArgs extends EventArgs
|
class WriteEvent extends Event
|
||||||
{
|
{
|
||||||
private $targetPath;
|
private $targetPath;
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
<tag name="kernel.cache_warmer" />
|
<tag name="kernel.cache_warmer" />
|
||||||
<argument type="service" id="assetic.asset_manager" />
|
<argument type="service" id="assetic.asset_manager" />
|
||||||
<argument type="service" id="assetic.asset_writer" />
|
<argument type="service" id="assetic.asset_writer" />
|
||||||
<argument type="service" id="event_manager" />
|
<argument type="service" id="event_dispatcher" />
|
||||||
</service>
|
</service>
|
||||||
<service id="assetic.asset_writer" class="%assetic.asset_writer.class%" public="false">
|
<service id="assetic.asset_writer" class="%assetic.asset_writer.class%" public="false">
|
||||||
<argument>%assetic.write_to%</argument>
|
<argument>%assetic.write_to%</argument>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Bundle\AsseticBundle\Tests\CacheWarmer;
|
namespace Symfony\Bundle\AsseticBundle\Tests\CacheWarmer;
|
||||||
|
|
||||||
use Symfony\Bundle\AsseticBundle\CacheWarmer\AssetWriterCacheWarmer;
|
use Symfony\Bundle\AsseticBundle\CacheWarmer\AssetWriterCacheWarmer;
|
||||||
use Symfony\Bundle\AsseticBundle\Event\WriteEventArgs;
|
use Symfony\Bundle\AsseticBundle\Event\WriteEvent;
|
||||||
use Symfony\Bundle\AsseticBundle\Events;
|
use Symfony\Bundle\AsseticBundle\Events;
|
||||||
|
|
||||||
class AssetWriterCacheWarmerTest extends \PHPUnit_Framework_TestCase
|
class AssetWriterCacheWarmerTest extends \PHPUnit_Framework_TestCase
|
||||||
@ -30,18 +30,18 @@ class AssetWriterCacheWarmerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$writer = $this->getMockBuilder('Assetic\\AssetWriter')
|
$writer = $this->getMockBuilder('Assetic\\AssetWriter')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->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')
|
->method('dispatchEvent')
|
||||||
->with(Events::onAsseticWrite, $eventArgs);
|
->with(Events::onAsseticWrite, $event);
|
||||||
$writer->expects($this->once())
|
$writer->expects($this->once())
|
||||||
->method('writeManagerAssets')
|
->method('writeManagerAssets')
|
||||||
->with($am);
|
->with($am);
|
||||||
|
|
||||||
$warmer = new AssetWriterCacheWarmer($am, $writer, $evm);
|
$warmer = new AssetWriterCacheWarmer($am, $writer, $dispatcher);
|
||||||
$warmer->warmUp('/path/to/cache');
|
$warmer->warmUp('/path/to/cache');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class ConnectionFactory
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a connection by name.
|
* Create a connection by name.
|
||||||
*
|
*
|
||||||
* @param string $connectionName
|
* @param string $connectionName
|
||||||
* @return Doctrine\DBAL\Connection
|
* @return Doctrine\DBAL\Connection
|
||||||
*/
|
*/
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
namespace Symfony\Bundle\FrameworkBundle;
|
namespace Symfony\Bundle\FrameworkBundle;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
use Doctrine\Common\EventArgs;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lazily loads listeners and subscribers from the dependency injection
|
* Lazily loads listeners and subscribers from the dependency injection
|
||||||
@ -22,7 +22,7 @@ use Doctrine\Common\EventArgs;
|
|||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||||
*/
|
*/
|
||||||
class ContainerAwareEventManager extends EventManager
|
class ContainerAwareEventDispatcher extends EventDispatcher
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The container from where services are loaded
|
* 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
|
* Lazily loads listeners for this event from the dependency injection
|
||||||
* container.
|
* container.
|
||||||
*/
|
*/
|
||||||
public function dispatchEvent($eventName, EventArgs $eventArgs = null)
|
public function dispatchEvent($eventName, Event $event = null)
|
||||||
{
|
{
|
||||||
if (isset($this->listenerIds[$eventName])) {
|
if (isset($this->listenerIds[$eventName])) {
|
||||||
foreach ($this->listenerIds[$eventName] as $serviceId => $priority) {
|
foreach ($this->listenerIds[$eventName] as $serviceId => $priority) {
|
||||||
@ -100,6 +100,6 @@ class ContainerAwareEventManager extends EventManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::dispatchEvent($eventName, $eventArgs);
|
parent::dispatchEvent($eventName, $event);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,18 +11,18 @@
|
|||||||
|
|
||||||
namespace Symfony\Bundle\FrameworkBundle\Debug;
|
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\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\Debug\TraceableEventManagerInterface;
|
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcherInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Doctrine\Common\EventArgs;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends the ContainerAwareEventManager to add some debugging tools.
|
* Extends the ContainerAwareEventDispatcher to add some debugging tools.
|
||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class TraceableEventManager extends ContainerAwareEventManager implements TraceableEventManagerInterface
|
class TraceableEventDispatcher extends ContainerAwareEventDispatcher implements TraceableEventDispatcherInterface
|
||||||
{
|
{
|
||||||
protected $logger;
|
protected $logger;
|
||||||
protected $called;
|
protected $called;
|
||||||
@ -44,9 +44,9 @@ class TraceableEventManager extends ContainerAwareEventManager implements Tracea
|
|||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@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);
|
$listenerString = $this->listenerToString($listener);
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ class TraceableEventManager extends ContainerAwareEventManager implements Tracea
|
|||||||
'listener' => $listenerString,
|
'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));
|
$this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s"', $this->listenerToString($listener), $eventName));
|
||||||
|
|
||||||
$skippedListeners = $this->getListeners($eventName);
|
$skippedListeners = $this->getListeners($eventName);
|
||||||
|
@ -19,12 +19,12 @@ class RegisterKernelListenersPass implements CompilerPassInterface
|
|||||||
{
|
{
|
||||||
public function process(ContainerBuilder $container)
|
public function process(ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
if (!$container->hasDefinition('event_manager')) {
|
if (!$container->hasDefinition('event_dispatcher')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$listeners = array();
|
$listeners = array();
|
||||||
$definition = $container->getDefinition('event_manager');
|
$definition = $container->getDefinition('event_dispatcher');
|
||||||
|
|
||||||
foreach ($container->findTaggedServiceIds('kernel.listener') as $id => $events) {
|
foreach ($container->findTaggedServiceIds('kernel.listener') as $id => $events) {
|
||||||
foreach ($events as $event) {
|
foreach ($events as $event) {
|
||||||
|
@ -51,8 +51,8 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
if ($container->getParameter('kernel.debug')) {
|
if ($container->getParameter('kernel.debug')) {
|
||||||
$loader->load('debug.xml');
|
$loader->load('debug.xml');
|
||||||
$container->setDefinition('event_manager', $container->findDefinition('debug.event_manager'));
|
$container->setDefinition('event_dispatcher', $container->findDefinition('debug.event_dispatcher'));
|
||||||
$container->setAlias('debug.event_manager', 'event_manager');
|
$container->setAlias('debug.event_dispatcher', 'event_dispatcher');
|
||||||
}
|
}
|
||||||
|
|
||||||
$processor = new Processor();
|
$processor = new Processor();
|
||||||
@ -140,12 +140,12 @@ class FrameworkExtension extends Extension
|
|||||||
'Symfony\\Component\\HttpKernel\\ResponseListener',
|
'Symfony\\Component\\HttpKernel\\ResponseListener',
|
||||||
'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver',
|
'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolver',
|
||||||
'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface',
|
'Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface',
|
||||||
'Symfony\\Component\\HttpKernel\\Event\\KernelEventArgs',
|
'Symfony\\Component\\HttpKernel\\Event\\KernelEvent',
|
||||||
'Symfony\\Component\\HttpKernel\\Event\\FilterControllerEventArgs',
|
'Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent',
|
||||||
'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEventArgs',
|
'Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent',
|
||||||
'Symfony\\Component\\HttpKernel\\Event\\GetResponseEventArgs',
|
'Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent',
|
||||||
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEventArgs',
|
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent',
|
||||||
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEventArgs',
|
'Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent',
|
||||||
'Symfony\\Component\\HttpKernel\\Events',
|
'Symfony\\Component\\HttpKernel\\Events',
|
||||||
|
|
||||||
'Symfony\\Bundle\\FrameworkBundle\\RequestListener',
|
'Symfony\\Bundle\\FrameworkBundle\\RequestListener',
|
||||||
@ -153,11 +153,12 @@ class FrameworkExtension extends Extension
|
|||||||
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver',
|
'Symfony\\Bundle\\FrameworkBundle\\Controller\\ControllerResolver',
|
||||||
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
|
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
|
||||||
|
|
||||||
'Symfony\\Bundle\\FrameworkBundle\\ContainerAwareEventManager',
|
'Symfony\\Bundle\\FrameworkBundle\\ContainerAwareEventDispatcher',
|
||||||
|
|
||||||
'Doctrine\\Common\\EventManager',
|
'Symfony\\Component\\EventDispatcher\\EventDispatcher',
|
||||||
'Doctrine\\Common\\EventArgs',
|
'Symfony\\Component\\EventDispatcher\\EventDispatcherInterface',
|
||||||
'Doctrine\\Common\\EventSubscriber',
|
'Symfony\\Component\\EventDispatcher\\Event',
|
||||||
|
'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\HttpFoundation;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SessionListener.
|
* SessionListener.
|
||||||
@ -29,12 +29,12 @@ class SessionListener
|
|||||||
* Checks if session was initialized and saves if current request is master
|
* Checks if session was initialized and saves if current request is master
|
||||||
* Runs on 'filterCoreResponse' in test environment
|
* 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 ($request = $event->getRequest()) {
|
||||||
if (HttpKernelInterface::MASTER_REQUEST === $eventArgs->getRequestType()) {
|
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
|
||||||
if ($session = $request->getSession()) {
|
if ($session = $request->getSession()) {
|
||||||
$session->save();
|
$session->save();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|||||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\HttpKernel\HttpKernel as BaseHttpKernel;
|
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.
|
* This HttpKernel is used to manage scope changes of the DI container.
|
||||||
@ -19,9 +19,9 @@ class HttpKernel extends BaseHttpKernel
|
|||||||
private $container;
|
private $container;
|
||||||
private $esiSupport;
|
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;
|
$this->container = $container;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Profiler;
|
|||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
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\HttpFoundation\RequestMatcherInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
|
|
||||||
@ -46,29 +46,29 @@ class ProfilerListener
|
|||||||
/**
|
/**
|
||||||
* Handles the onCoreException event.
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->exception = $eventArgs->getException();
|
$this->exception = $event->getException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the filterCoreResponse event.
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->matcher && !$this->matcher->matches($eventArgs->getRequest())) {
|
if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ class ProfilerListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->container->get('profiler')->collect($eventArgs->getRequest(), $response, $this->exception);
|
$this->container->get('profiler')->collect($event->getRequest(), $response, $this->exception);
|
||||||
$this->exception = null;
|
$this->exception = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle;
|
|||||||
|
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
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\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\RouterInterface;
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
@ -36,10 +36,10 @@ class RequestListener
|
|||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCoreRequest(GetResponseEventArgs $eventArgs)
|
public function onCoreRequest(GetResponseEvent $event)
|
||||||
{
|
{
|
||||||
$request = $eventArgs->getRequest();
|
$request = $event->getRequest();
|
||||||
$master = HttpKernelInterface::MASTER_REQUEST === $eventArgs->getRequestType();
|
$master = HttpKernelInterface::MASTER_REQUEST === $event->getRequestType();
|
||||||
|
|
||||||
$this->initializeSession($request, $master);
|
$this->initializeSession($request, $master);
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
|
|
||||||
<service id="data_collector.events" class="%data_collector.events.class%" public="false">
|
<service id="data_collector.events" class="%data_collector.events.class%" public="false">
|
||||||
<tag name="data_collector" template="WebProfilerBundle:Collector:events" id="events" priority="255" />
|
<tag name="data_collector" template="WebProfilerBundle:Collector:events" id="events" priority="255" />
|
||||||
<call method="setEventManager">
|
<call method="setEventDispatcher">
|
||||||
<argument type="service" id="event_manager" />
|
<argument type="service" id="event_dispatcher" />
|
||||||
</call>
|
</call>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
<parameters>
|
<parameters>
|
||||||
<parameter key="debug.event_manager.class">Symfony\Bundle\FrameworkBundle\Debug\TraceableEventManager</parameter>
|
<parameter key="debug.event_dispatcher.class">Symfony\Bundle\FrameworkBundle\Debug\TraceableEventDispatcher</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="debug.event_manager" class="%debug.event_manager.class%">
|
<service id="debug.event_dispatcher" class="%debug.event_dispatcher.class%">
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
<argument type="service" id="logger" on-invalid="null" />
|
<argument type="service" id="logger" on-invalid="null" />
|
||||||
</service>
|
</service>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||||
|
|
||||||
<parameters>
|
<parameters>
|
||||||
<parameter key="event_manager.class">Symfony\Bundle\FrameworkBundle\ContainerAwareEventManager</parameter>
|
<parameter key="event_dispatcher.class">Symfony\Bundle\FrameworkBundle\ContainerAwareEventDispatcher</parameter>
|
||||||
<parameter key="http_kernel.class">Symfony\Bundle\FrameworkBundle\HttpKernel</parameter>
|
<parameter key="http_kernel.class">Symfony\Bundle\FrameworkBundle\HttpKernel</parameter>
|
||||||
<parameter key="error_handler.class">Symfony\Component\HttpKernel\Debug\ErrorHandler</parameter>
|
<parameter key="error_handler.class">Symfony\Component\HttpKernel\Debug\ErrorHandler</parameter>
|
||||||
<parameter key="error_handler.level">null</parameter>
|
<parameter key="error_handler.level">null</parameter>
|
||||||
@ -16,7 +16,7 @@
|
|||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="event_manager" class="%event_manager.class%">
|
<service id="event_dispatcher" class="%event_dispatcher.class%">
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
@ -25,7 +25,7 @@
|
|||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="http_kernel" class="%http_kernel.class%">
|
<service id="http_kernel" class="%http_kernel.class%">
|
||||||
<argument type="service" id="event_manager" />
|
<argument type="service" id="event_dispatcher" />
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
<argument type="service" id="controller_resolver" />
|
<argument type="service" id="controller_resolver" />
|
||||||
</service>
|
</service>
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Bundle\FrameworkBundle\HttpFoundation\SessionListener;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SessionListenerTest.
|
* SessionListenerTest.
|
||||||
@ -54,11 +54,11 @@ class SessionListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$request->setSession($this->session);
|
$request->setSession($this->session);
|
||||||
$response = new Response();
|
$response = new Response();
|
||||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
$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()
|
private function sessionMustNotBeSaved()
|
||||||
|
@ -7,7 +7,7 @@ use Symfony\Component\HttpFoundation\Response;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Bundle\FrameworkBundle\HttpKernel;
|
use Symfony\Bundle\FrameworkBundle\HttpKernel;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
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'))
|
->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
||||||
$kernel = new HttpKernel($evm, $container, $resolver);
|
$kernel = new HttpKernel($dispatcher, $container, $resolver);
|
||||||
|
|
||||||
$controller = function() use($expected)
|
$controller = function() use($expected)
|
||||||
{
|
{
|
||||||
@ -84,9 +84,9 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
|||||||
->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request'))
|
->with($this->equalTo('request'), $this->equalTo($request), $this->equalTo('request'))
|
||||||
;
|
;
|
||||||
|
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
||||||
$kernel = new HttpKernel($evm, $container, $resolver);
|
$kernel = new HttpKernel($dispatcher, $container, $resolver);
|
||||||
|
|
||||||
$controller = function() use ($expected)
|
$controller = function() use ($expected)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@
|
|||||||
<service id="security.firewall" class="%security.firewall.class%">
|
<service id="security.firewall" class="%security.firewall.class%">
|
||||||
<tag name="kernel.listener" event="onCoreRequest" priority="-128" />
|
<tag name="kernel.listener" event="onCoreRequest" priority="-128" />
|
||||||
<argument type="service" id="security.firewall.map" />
|
<argument type="service" id="security.firewall.map" />
|
||||||
<argument type="service" id="event_manager" />
|
<argument type="service" id="event_dispatcher" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="security.firewall.map" class="%security.firewall.map.class%" public="false">
|
<service id="security.firewall.map" class="%security.firewall.map.class%" public="false">
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Symfony\Bundle\SecurityBundle;
|
namespace Symfony\Bundle\SecurityBundle;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -13,10 +13,10 @@ use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
|||||||
*/
|
*/
|
||||||
class ResponseListener
|
class ResponseListener
|
||||||
{
|
{
|
||||||
public function filterCoreResponse(FilterResponseEventArgs $eventArgs)
|
public function filterCoreResponse(FilterResponseEvent $event)
|
||||||
{
|
{
|
||||||
$request = $eventArgs->getRequest();
|
$request = $event->getRequest();
|
||||||
$response = $eventArgs->getResponse();
|
$response = $event->getResponse();
|
||||||
|
|
||||||
if ($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME)) {
|
if ($request->attributes->has(RememberMeServicesInterface::COOKIE_ATTR_NAME)) {
|
||||||
$response->headers->setCookie($request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME));
|
$response->headers->setCookie($request->attributes->get(RememberMeServicesInterface::COOKIE_ATTR_NAME));
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Bundle\FrameworkBundle\HttpKernel;
|
use Symfony\Bundle\FrameworkBundle\HttpKernel;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Bundle\TwigBundle\TwigEngine;
|
use Symfony\Bundle\TwigBundle\TwigEngine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,14 +41,14 @@ class WebDebugToolbarListener
|
|||||||
$this->interceptRedirects = $interceptRedirects;
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $eventArgs->getResponse();
|
$response = $event->getResponse();
|
||||||
$request = $eventArgs->getRequest();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects) {
|
if ($response->headers->has('X-Debug-Token') && $response->isRedirect() && $this->interceptRedirects) {
|
||||||
// keep current flashes for one more request
|
// keep current flashes for one more request
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
namespace Symfony\Component\EventDispatcher;
|
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
|
* Listeners are registered on the manager and events are dispatched through the
|
||||||
* manager.
|
* manager.
|
||||||
*
|
*
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Symfony\Component\EventDispatcher;
|
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
|
* Listeners are registered on the manager and events are dispatched through the
|
||||||
* manager.
|
* manager.
|
||||||
*
|
*
|
||||||
|
@ -24,7 +24,7 @@ namespace Symfony\Component\EventDispatcher;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An EventSubscriber knows himself what events he is interested in.
|
* 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
|
* {@link getSubscribedEvents} and registers the subscriber as a listener for all
|
||||||
* returned events.
|
* returned events.
|
||||||
*
|
*
|
||||||
|
@ -13,8 +13,8 @@ namespace Symfony\Component\HttpKernel\DataCollector;
|
|||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Debug\TraceableEventManagerInterface;
|
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcherInterface;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EventDataCollector.
|
* EventDataCollector.
|
||||||
@ -23,12 +23,12 @@ use Doctrine\Common\EventManager;
|
|||||||
*/
|
*/
|
||||||
class EventDataCollector extends DataCollector
|
class EventDataCollector extends DataCollector
|
||||||
{
|
{
|
||||||
protected $evm;
|
protected $dispatcher;
|
||||||
|
|
||||||
public function setEventManager(EventManager $evm)
|
public function setEventDispatcher(EventDispatcherInterface $dispatcher)
|
||||||
{
|
{
|
||||||
if ($evm instanceof TraceableEventManagerInterface) {
|
if ($dispatcher instanceof TraceableEventDispatcherInterface) {
|
||||||
$this->evm = $evm;
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,8 +38,8 @@ class EventDataCollector extends DataCollector
|
|||||||
public function collect(Request $request, Response $response, \Exception $exception = null)
|
public function collect(Request $request, Response $response, \Exception $exception = null)
|
||||||
{
|
{
|
||||||
$this->data = array(
|
$this->data = array(
|
||||||
'called_listeners' => null !== $this->evm ? $this->evm->getCalledListeners() : array(),
|
'called_listeners' => null !== $this->dispatcher ? $this->dispatcher->getCalledListeners() : array(),
|
||||||
'not_called_listeners' => null !== $this->evm ? $this->evm->getNotCalledListeners() : 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
|
* @return array An array of called listeners
|
||||||
*
|
*
|
||||||
* @see TraceableEventManagerInterface
|
* @see TraceableEventDispatcherInterface
|
||||||
*/
|
*/
|
||||||
public function getCalledListeners()
|
public function getCalledListeners()
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ class EventDataCollector extends DataCollector
|
|||||||
*
|
*
|
||||||
* @return array An array of not called listeners
|
* @return array An array of not called listeners
|
||||||
*
|
*
|
||||||
* @see TraceableEventManagerInterface
|
* @see TraceableEventDispatcherInterface
|
||||||
*/
|
*/
|
||||||
public function getNotCalledListeners()
|
public function getNotCalledListeners()
|
||||||
{
|
{
|
||||||
|
@ -48,7 +48,7 @@ class LoggerDataCollector extends DataCollector
|
|||||||
*
|
*
|
||||||
* @return array An array of called events
|
* @return array An array of called events
|
||||||
*
|
*
|
||||||
* @see TraceableEventManagerInterface
|
* @see TraceableEventDispatcherInterface
|
||||||
*/
|
*/
|
||||||
public function countErrors()
|
public function countErrors()
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\Debug;
|
|||||||
|
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
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\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
@ -34,7 +34,7 @@ class ExceptionListener
|
|||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCoreException(GetResponseForExceptionEventArgs $eventArgs)
|
public function onCoreException(GetResponseForExceptionEvent $event)
|
||||||
{
|
{
|
||||||
static $handling;
|
static $handling;
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ class ExceptionListener
|
|||||||
|
|
||||||
$handling = true;
|
$handling = true;
|
||||||
|
|
||||||
$exception = $eventArgs->getException();
|
$exception = $event->getException();
|
||||||
$request = $eventArgs->getRequest();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->err(sprintf('%s: %s (uncaught exception)', get_class($exception), $exception->getMessage()));
|
$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);
|
$request = $request->duplicate(null, null, $attributes);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $eventArgs->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, true);
|
$response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, true);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
|
$message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage());
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
@ -82,7 +82,7 @@ class ExceptionListener
|
|||||||
throw $exception;
|
throw $exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
$eventArgs->setResponse($response);
|
$event->setResponse($response);
|
||||||
|
|
||||||
$handling = false;
|
$handling = false;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Debug;
|
|||||||
/**
|
/**
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
interface TraceableEventManagerInterface
|
interface TraceableEventDispatcherInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Gets the called listeners.
|
* Gets the called listeners.
|
@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class FilterControllerEventArgs extends KernelEventArgs
|
class FilterControllerEvent extends KernelEvent
|
||||||
{
|
{
|
||||||
private $controller;
|
private $controller;
|
||||||
|
|
@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class FilterResponseEventArgs extends KernelEventArgs
|
class FilterResponseEvent extends KernelEvent
|
||||||
{
|
{
|
||||||
private $response;
|
private $response;
|
||||||
|
|
@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class GetResponseEventArgs extends KernelEventArgs
|
class GetResponseEvent extends KernelEvent
|
||||||
{
|
{
|
||||||
private $response;
|
private $response;
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class GetResponseForControllerResultEventArgs extends GetResponseEventArgs
|
class GetResponseForControllerResultEvent extends GetResponseEvent
|
||||||
{
|
{
|
||||||
private $controllerResult;
|
private $controllerResult;
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
class GetResponseForExceptionEventArgs extends GetResponseEventArgs
|
class GetResponseForExceptionEvent extends GetResponseEvent
|
||||||
{
|
{
|
||||||
private $exception;
|
private $exception;
|
||||||
|
|
@ -13,9 +13,9 @@ namespace Symfony\Component\HttpKernel\Event;
|
|||||||
|
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Doctrine\Common\EventArgs;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
class KernelEventArgs extends EventArgs
|
class KernelEvent extends Event
|
||||||
{
|
{
|
||||||
private $kernel;
|
private $kernel;
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Symfony\Component\HttpKernel\HttpCache;
|
|||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
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.
|
* 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.
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->esi->addSurrogateControl($eventArgs->getResponse());
|
$this->esi->addSurrogateControl($event->getResponse());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,14 +13,14 @@ namespace Symfony\Component\HttpKernel;
|
|||||||
|
|
||||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterControllerEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
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.
|
* HttpKernel notifies events to convert a Request object to a Response one.
|
||||||
@ -29,18 +29,18 @@ use Doctrine\Common\EventManager;
|
|||||||
*/
|
*/
|
||||||
class HttpKernel implements HttpKernelInterface
|
class HttpKernel implements HttpKernelInterface
|
||||||
{
|
{
|
||||||
private $evm;
|
private $dispatcher;
|
||||||
private $resolver;
|
private $resolver;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param EventManager $evm An EventManager instance
|
* @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance
|
||||||
* @param ControllerResolverInterface $resolver A ControllerResolverInterface 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;
|
$this->resolver = $resolver;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,14 +57,14 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// exception
|
// exception
|
||||||
$eventArgs = new GetResponseForExceptionEventArgs($this, $request, $type, $e);
|
$event = new GetResponseForExceptionEvent($this, $request, $type, $e);
|
||||||
$this->evm->dispatchEvent(Events::onCoreException, $eventArgs);
|
$this->dispatcher->dispatchEvent(Events::onCoreException, $event);
|
||||||
|
|
||||||
if (!$eventArgs->hasResponse()) {
|
if (!$event->hasResponse()) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->filterResponse($eventArgs->getResponse(), $request, $type);
|
$response = $this->filterResponse($event->getResponse(), $request, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
@ -86,11 +86,11 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
protected function handleRaw(Request $request, $type = self::MASTER_REQUEST)
|
protected function handleRaw(Request $request, $type = self::MASTER_REQUEST)
|
||||||
{
|
{
|
||||||
// request
|
// request
|
||||||
$eventArgs = new GetResponseEventArgs($this, $request, $type);
|
$event = new GetResponseEvent($this, $request, $type);
|
||||||
$this->evm->dispatchEvent(Events::onCoreRequest, $eventArgs);
|
$this->dispatcher->dispatchEvent(Events::onCoreRequest, $event);
|
||||||
|
|
||||||
if ($eventArgs->hasResponse()) {
|
if ($event->hasResponse()) {
|
||||||
return $this->filterResponse($eventArgs->getResponse(), $request, $type);
|
return $this->filterResponse($event->getResponse(), $request, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load controller
|
// 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()));
|
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);
|
$event = new FilterControllerEvent($this, $controller, $request, $type);
|
||||||
$this->evm->dispatchEvent(Events::filterCoreController, $eventArgs);
|
$this->dispatcher->dispatchEvent(Events::filterCoreController, $event);
|
||||||
$controller = $eventArgs->getController();
|
$controller = $event->getController();
|
||||||
|
|
||||||
// controller arguments
|
// controller arguments
|
||||||
$arguments = $this->resolver->getArguments($request, $controller);
|
$arguments = $this->resolver->getArguments($request, $controller);
|
||||||
@ -110,11 +110,11 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
|
|
||||||
// view
|
// view
|
||||||
if (!$response instanceof Response) {
|
if (!$response instanceof Response) {
|
||||||
$eventArgs = new GetResponseForControllerResultEventArgs($this, $request, $type, $response);
|
$event = new GetResponseForControllerResultEvent($this, $request, $type, $response);
|
||||||
$this->evm->dispatchEvent(Events::onCoreView, $eventArgs);
|
$this->dispatcher->dispatchEvent(Events::onCoreView, $event);
|
||||||
|
|
||||||
if ($eventArgs->hasResponse()) {
|
if ($event->hasResponse()) {
|
||||||
$response = $eventArgs->getResponse();
|
$response = $event->getResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$response instanceof Response) {
|
if (!$response instanceof Response) {
|
||||||
@ -138,11 +138,11 @@ class HttpKernel implements HttpKernelInterface
|
|||||||
*/
|
*/
|
||||||
protected function filterResponse(Response $response, Request $request, $type)
|
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)
|
protected function varToString($var)
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\HttpKernel;
|
namespace Symfony\Component\HttpKernel;
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,15 +31,15 @@ class ResponseListener
|
|||||||
/**
|
/**
|
||||||
* Filters the Response.
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $eventArgs->getResponse();
|
$response = $event->getResponse();
|
||||||
|
|
||||||
if (null === $response->getCharset()) {
|
if (null === $response->getCharset()) {
|
||||||
$response->setCharset($this->charset);
|
$response->setCharset($this->charset);
|
||||||
@ -49,7 +49,7 @@ class ResponseListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $eventArgs->getRequest();
|
$request = $event->getRequest();
|
||||||
$format = $request->getRequestFormat();
|
$format = $request->getRequestFormat();
|
||||||
if ((null !== $format) && $mimeType = $request->getMimeType($format)) {
|
if ((null !== $format) && $mimeType = $request->getMimeType($format)) {
|
||||||
$response->headers->set('Content-Type', $mimeType);
|
$response->headers->set('Content-Type', $mimeType);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Security\Http\Authentication;
|
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\Security\Core\Exception\AuthenticationException;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
@ -22,12 +22,12 @@ interface AuthenticationFailureHandlerInterface
|
|||||||
* called by authentication listeners inheriting from
|
* called by authentication listeners inheriting from
|
||||||
* AbstractAuthenticationListener.
|
* AbstractAuthenticationListener.
|
||||||
*
|
*
|
||||||
* @param GetResponseEventArgs $eventArgs the "onCoreSecurity" event, this event always
|
* @param GetResponseEvent $event the "onCoreSecurity" event, this event always
|
||||||
* has the kernel as target
|
* has the kernel as target
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param AuthenticationException $exception
|
* @param AuthenticationException $exception
|
||||||
*
|
*
|
||||||
* @return Response the response to return
|
* @return Response the response to return
|
||||||
*/
|
*/
|
||||||
function onAuthenticationFailure(GetResponseEventArgs $eventArgs, Request $request, AuthenticationException $exception);
|
function onAuthenticationFailure(GetResponseEvent $event, Request $request, AuthenticationException $exception);
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Security\Http\Authentication;
|
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\Security\Core\Authentication\Token\TokenInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
@ -22,12 +22,12 @@ interface AuthenticationSuccessHandlerInterface
|
|||||||
* is called by authentication listeners inheriting from
|
* is called by authentication listeners inheriting from
|
||||||
* AbstractAuthenticationListener.
|
* AbstractAuthenticationListener.
|
||||||
*
|
*
|
||||||
* @param GetResponseEventArgs $eventArgs the "onCoreSecurity" event, this event always
|
* @param GetResponseEvent $event the "onCoreSecurity" event, this event always
|
||||||
* has the kernel as target
|
* has the kernel as target
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param TokenInterface $token
|
* @param TokenInterface $token
|
||||||
*
|
*
|
||||||
* @return Response the response to return
|
* @return Response the response to return
|
||||||
*/
|
*/
|
||||||
function onAuthenticationSuccess(GetResponseEventArgs $eventArgs, Request $request, TokenInterface $token);
|
function onAuthenticationSuccess(GetResponseEvent $event, Request $request, TokenInterface $token);
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
namespace Symfony\Component\Security\Http\Authorization;
|
namespace Symfony\Component\Security\Http\Authorization;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Event\ExceptionEventArgs;
|
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -17,11 +17,11 @@ interface AccessDeniedHandlerInterface
|
|||||||
/**
|
/**
|
||||||
* Handles an access denied failure.
|
* Handles an access denied failure.
|
||||||
*
|
*
|
||||||
* @param ExceptionEventArgs $eventArgs
|
* @param ExceptionEvent $event
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param AccessDeniedException $accessDeniedException
|
* @param AccessDeniedException $accessDeniedException
|
||||||
*
|
*
|
||||||
* @return Response may return null
|
* @return Response may return null
|
||||||
*/
|
*/
|
||||||
function handle(ExceptionEventArgs $eventArgs, Request $request, AccessDeniedException $accessDeniedException);
|
function handle(ExceptionEvent $event, Request $request, AccessDeniedException $accessDeniedException);
|
||||||
}
|
}
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Security\Http\EntryPoint;
|
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\Security\Core\Exception\AuthenticationException;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
@ -26,9 +26,9 @@ interface AuthenticationEntryPointInterface
|
|||||||
/**
|
/**
|
||||||
* Starts the authentication scheme.
|
* 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 object $request The request that resulted in an AuthenticationException
|
||||||
* @param AuthenticationException $authException The exception that started the authentication process
|
* @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);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
|||||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BasicAuthenticationEntryPoint starts an HTTP Basic authentication.
|
* BasicAuthenticationEntryPoint starts an HTTP Basic authentication.
|
||||||
@ -31,7 +31,7 @@ class BasicAuthenticationEntryPoint implements AuthenticationEntryPointInterface
|
|||||||
$this->realmName = $realmName;
|
$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 = new Response();
|
||||||
$response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', $this->realmName));
|
$response->headers->set('WWW-Authenticate', sprintf('Basic realm="%s"', $this->realmName));
|
||||||
|
@ -17,7 +17,7 @@ use Symfony\Component\Security\Core\Exception\NonceExpiredException;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DigestAuthenticationEntryPoint starts an HTTP Digest authentication.
|
* DigestAuthenticationEntryPoint starts an HTTP Digest authentication.
|
||||||
@ -39,7 +39,7 @@ class DigestAuthenticationEntryPoint implements AuthenticationEntryPointInterfac
|
|||||||
$this->logger = $logger;
|
$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;
|
$expiryTime = microtime(true) + $this->nonceValiditySeconds * 1000;
|
||||||
$signatureValue = md5($expiryTime.':'.$this->key);
|
$signatureValue = md5($expiryTime.':'.$this->key);
|
||||||
|
@ -17,7 +17,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
|
|||||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
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.
|
* FormAuthenticationEntryPoint starts an authentication via a login form.
|
||||||
@ -44,7 +44,7 @@ class FormAuthenticationEntryPoint implements AuthenticationEntryPointInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function start(GetResponseEventArgs $eventArgs, Request $request, AuthenticationException $authException = null)
|
public function start(GetResponseEvent $event, Request $request, AuthenticationException $authException = null)
|
||||||
{
|
{
|
||||||
if ($this->useForward) {
|
if ($this->useForward) {
|
||||||
return $event->getKernel()->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST);
|
return $event->getKernel()->handle(Request::create($this->loginPath), HttpKernelInterface::SUB_REQUEST);
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
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.
|
* RetryAuthenticationEntryPoint redirects URL based on the configured scheme.
|
||||||
@ -36,7 +36,7 @@ class RetryAuthenticationEntryPoint implements AuthenticationEntryPointInterface
|
|||||||
$this->httpsPort = $httpsPort;
|
$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';
|
$scheme = $request->isSecure() ? 'http' : 'https';
|
||||||
if ('http' === $scheme && 80 != $this->httpPort) {
|
if ('http' === $scheme && 80 != $this->httpPort) {
|
||||||
|
@ -12,9 +12,9 @@
|
|||||||
namespace Symfony\Component\Security\Http\Event;
|
namespace Symfony\Component\Security\Http\Event;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Doctrine\Common\EventArgs;
|
use Symfony\Component\EventDispatcher\Event;
|
||||||
|
|
||||||
class InteractiveLoginEventArgs extends EventArgs
|
class InteractiveLoginEvent extends Event
|
||||||
{
|
{
|
||||||
private $request;
|
private $request;
|
||||||
|
|
@ -13,9 +13,9 @@ namespace Symfony\Component\Security\Http\Event;
|
|||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
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;
|
private $request;
|
||||||
|
|
@ -13,9 +13,9 @@ namespace Symfony\Component\Security\Http;
|
|||||||
|
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Events;
|
use Symfony\Component\HttpKernel\Events;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
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
|
* Firewall uses a FirewallMap to register security listeners for the given
|
||||||
@ -30,7 +30,7 @@ use Doctrine\Common\EventManager;
|
|||||||
class Firewall
|
class Firewall
|
||||||
{
|
{
|
||||||
private $map;
|
private $map;
|
||||||
private $evm;
|
private $dispatcher;
|
||||||
private $currentListeners;
|
private $currentListeners;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,35 +38,35 @@ class Firewall
|
|||||||
*
|
*
|
||||||
* @param FirewallMap $map A FirewallMap instance
|
* @param FirewallMap $map A FirewallMap instance
|
||||||
*/
|
*/
|
||||||
public function __construct(FirewallMapInterface $map, EventManager $evm)
|
public function __construct(FirewallMapInterface $map, EventDispatcherInterface $dispatcher)
|
||||||
{
|
{
|
||||||
$this->map = $map;
|
$this->map = $map;
|
||||||
$this->evm = $evm;
|
$this->dispatcher = $dispatcher;
|
||||||
$this->currentListeners = array();
|
$this->currentListeners = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles security.
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// register listeners for this firewall
|
// register listeners for this firewall
|
||||||
list($listeners, $exception) = $this->map->getListeners($eventArgs->getRequest());
|
list($listeners, $exception) = $this->map->getListeners($event->getRequest());
|
||||||
if (null !== $exception) {
|
if (null !== $exception) {
|
||||||
$exception->register($this->evm);
|
$exception->register($this->dispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
// initiate the listener chain
|
// initiate the listener chain
|
||||||
foreach ($listeners as $listener) {
|
foreach ($listeners as $listener) {
|
||||||
$response = $listener->handle($eventArgs);
|
$response = $listener->handle($event);
|
||||||
|
|
||||||
if ($eventArgs->hasResponse()) {
|
if ($event->hasResponse()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
|||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Events as KernelEvents;
|
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\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
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
|
* The AbstractAuthenticationListener is the preferred base class for all
|
||||||
@ -53,7 +53,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
|||||||
protected $providerKey;
|
protected $providerKey;
|
||||||
private $securityContext;
|
private $securityContext;
|
||||||
private $sessionStrategy;
|
private $sessionStrategy;
|
||||||
private $evm;
|
private $dispatcher;
|
||||||
private $successHandler;
|
private $successHandler;
|
||||||
private $failureHandler;
|
private $failureHandler;
|
||||||
private $rememberMeServices;
|
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 array $options An array of options for the processing of a successful, or failed authentication attempt
|
||||||
* @param LoggerInterface $logger A LoggerInterface instance
|
* @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)) {
|
if (empty($providerKey)) {
|
||||||
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
||||||
@ -89,7 +89,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
|||||||
'failure_forward' => false,
|
'failure_forward' => false,
|
||||||
), $options);
|
), $options);
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->evm = $evm;
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,9 +107,9 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
|||||||
*
|
*
|
||||||
* @param Event $event An Event instance
|
* @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)) {
|
if (!$this->requiresAuthentication($request)) {
|
||||||
return;
|
return;
|
||||||
@ -123,17 +123,17 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
|||||||
if ($returnValue instanceof TokenInterface) {
|
if ($returnValue instanceof TokenInterface) {
|
||||||
$this->sessionStrategy->onAuthentication($request, $returnValue);
|
$this->sessionStrategy->onAuthentication($request, $returnValue);
|
||||||
|
|
||||||
$response = $this->onSuccess($eventArgs, $request, $returnValue);
|
$response = $this->onSuccess($event, $request, $returnValue);
|
||||||
} else if ($returnValue instanceof Response) {
|
} else if ($returnValue instanceof Response) {
|
||||||
$response = $returnValue;
|
$response = $returnValue;
|
||||||
} else {
|
} else {
|
||||||
throw new \RuntimeException('attemptAuthentication() must either return a Response, an implementation of TokenInterface, or null.');
|
throw new \RuntimeException('attemptAuthentication() must either return a Response, an implementation of TokenInterface, or null.');
|
||||||
}
|
}
|
||||||
} catch (AuthenticationException $e) {
|
} 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);
|
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) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->debug(sprintf('Authentication request failed: %s', $failed->getMessage()));
|
$this->logger->debug(sprintf('Authentication request failed: %s', $failed->getMessage()));
|
||||||
@ -172,7 +172,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
|||||||
$this->securityContext->setToken(null);
|
$this->securityContext->setToken(null);
|
||||||
|
|
||||||
if (null !== $this->failureHandler) {
|
if (null !== $this->failureHandler) {
|
||||||
return $this->failureHandler->onAuthenticationFailure($eventArgs, $request, $failed);
|
return $this->failureHandler->onAuthenticationFailure($event, $request, $failed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $this->options['failure_path']) {
|
if (null === $this->options['failure_path']) {
|
||||||
@ -187,7 +187,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
|||||||
$subRequest = Request::create($this->options['failure_path']);
|
$subRequest = Request::create($this->options['failure_path']);
|
||||||
$subRequest->attributes->set(SecurityContextInterface::AUTHENTICATION_ERROR, $failed);
|
$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) {
|
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);
|
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) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->debug('User has been authenticated successfully');
|
$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::AUTHENTICATION_ERROR);
|
||||||
$session->remove(SecurityContextInterface::LAST_USERNAME);
|
$session->remove(SecurityContextInterface::LAST_USERNAME);
|
||||||
|
|
||||||
if (null !== $this->evm) {
|
if (null !== $this->dispatcher) {
|
||||||
$loginEventArgs = new InteractiveLoginEventArgs($request, $token);
|
$loginEvent = new InteractiveLoginEvent($request, $token);
|
||||||
$this->evm->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEventArgs);
|
$this->dispatcher->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->successHandler) {
|
if (null !== $this->successHandler) {
|
||||||
$response = $this->successHandler->onAuthenticationSuccess($eventArgs, $request, $token);
|
$response = $this->successHandler->onAuthenticationSuccess($event, $request, $token);
|
||||||
} else {
|
} else {
|
||||||
$path = $this->determineTargetUrl($request);
|
$path = $this->determineTargetUrl($request);
|
||||||
$response = new RedirectResponse(0 !== strpos($path, 'http') ? $request->getUriForPath($path) : $path, 302);
|
$response = new RedirectResponse(0 !== strpos($path, 'http') ? $request->getUriForPath($path) : $path, 302);
|
||||||
|
@ -15,13 +15,13 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
|
|||||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
|
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
|
||||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
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\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\Events as KernelEvents;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractPreAuthenticatedListener is the base class for all listener that
|
* AbstractPreAuthenticatedListener is the base class for all listener that
|
||||||
@ -36,25 +36,25 @@ abstract class AbstractPreAuthenticatedListener implements ListenerInterface
|
|||||||
private $securityContext;
|
private $securityContext;
|
||||||
private $authenticationManager;
|
private $authenticationManager;
|
||||||
private $providerKey;
|
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->securityContext = $securityContext;
|
||||||
$this->authenticationManager = $authenticationManager;
|
$this->authenticationManager = $authenticationManager;
|
||||||
$this->providerKey = $providerKey;
|
$this->providerKey = $providerKey;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->evm = $evm;
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles X509 authentication.
|
* 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) {
|
if (null !== $this->logger) {
|
||||||
$this->logger->debug(sprintf('Checking secure context token: %s', $this->securityContext->getToken()));
|
$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);
|
$this->securityContext->setToken($token);
|
||||||
|
|
||||||
if (null !== $this->evm) {
|
if (null !== $this->dispatcher) {
|
||||||
$loginEventArgs = new InteractiveLoginEventArgs($request, $token);
|
$loginEvent = new InteractiveLoginEvent($request, $token);
|
||||||
$this->evm->notify(Events::onSecurityInteractiveLogin, $loginEventArgs);
|
$this->dispatcher->notify(Events::onSecurityInteractiveLogin, $loginEvent);
|
||||||
}
|
}
|
||||||
} catch (AuthenticationException $failed) {
|
} catch (AuthenticationException $failed) {
|
||||||
$this->securityContext->setToken(null);
|
$this->securityContext->setToken(null);
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface
|
|||||||
use Symfony\Component\Security\Http\AccessMap;
|
use Symfony\Component\Security\Http\AccessMap;
|
||||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
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\HttpKernel\Events;
|
||||||
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
@ -46,15 +46,15 @@ class AccessListener implements ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* Handles access authorization.
|
* 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()) {
|
if (null === $token = $this->context->getToken()) {
|
||||||
throw new AuthenticationCredentialsNotFoundException('A Token was not found in the SecurityContext.');
|
throw new AuthenticationCredentialsNotFoundException('A Token was not found in the SecurityContext.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $eventArgs->getRequest();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
list($attributes, $channel) = $this->map->getPatterns($request);
|
list($attributes, $channel) = $this->map->getPatterns($request);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ namespace Symfony\Component\Security\Http\Firewall;
|
|||||||
|
|
||||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
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\HttpKernel\Events;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
||||||
|
|
||||||
@ -39,9 +39,9 @@ class AnonymousAuthenticationListener implements ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* Handles anonymous authentication.
|
* 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()) {
|
if (null !== $this->context->getToken()) {
|
||||||
return;
|
return;
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
|
|||||||
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
|
||||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
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\HttpKernel\Events;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||||
@ -51,11 +51,11 @@ class BasicAuthenticationListener implements ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* Handles basic authentication.
|
* 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)) {
|
if (false === $username = $request->server->get('PHP_AUTH_USER', false)) {
|
||||||
return;
|
return;
|
||||||
|
@ -14,7 +14,7 @@ namespace Symfony\Component\Security\Http\Firewall;
|
|||||||
use Symfony\Component\Security\Http\AccessMap;
|
use Symfony\Component\Security\Http\AccessMap;
|
||||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
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\HttpKernel\Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,11 +39,11 @@ class ChannelListener implements ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* Handles channel management.
|
* 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);
|
list($attributes, $channel) = $this->map->getPatterns($request);
|
||||||
|
|
||||||
@ -52,9 +52,9 @@ class ChannelListener implements ListenerInterface
|
|||||||
$this->logger->debug('Redirecting to HTTPS');
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
@ -64,9 +64,9 @@ class ChannelListener implements ListenerInterface
|
|||||||
$this->logger->debug('Redirecting to HTTP');
|
$this->logger->debug('Redirecting to HTTP');
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->authenticationEntryPoint->start($eventArgs, $request);
|
$response = $this->authenticationEntryPoint->start($event, $request);
|
||||||
|
|
||||||
$eventArgs->setResponse($response);
|
$event->setResponse($response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ namespace Symfony\Component\Security\Http\Firewall;
|
|||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\Events;
|
use Symfony\Component\HttpKernel\Events;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
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\Exception\UnsupportedUserException;
|
||||||
use Symfony\Component\Security\Core\SecurityContext;
|
use Symfony\Component\Security\Core\SecurityContext;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ContextListener manages the SecurityContext persistence through a session.
|
* ContextListener manages the SecurityContext persistence through a session.
|
||||||
@ -38,7 +38,7 @@ class ContextListener implements ListenerInterface
|
|||||||
private $logger;
|
private $logger;
|
||||||
private $userProviders;
|
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)) {
|
if (empty($contextKey)) {
|
||||||
throw new \InvalidArgumentException('$contextKey must not be empty.');
|
throw new \InvalidArgumentException('$contextKey must not be empty.');
|
||||||
@ -48,19 +48,19 @@ class ContextListener implements ListenerInterface
|
|||||||
$this->userProviders = $userProviders;
|
$this->userProviders = $userProviders;
|
||||||
$this->contextKey = $contextKey;
|
$this->contextKey = $contextKey;
|
||||||
|
|
||||||
if (null !== $evm) {
|
if (null !== $dispatcher) {
|
||||||
$evm->connect(Events::onCoreResponse, $this);
|
$dispatcher->connect(Events::onCoreResponse, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the SecurityContext from the session.
|
* 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;
|
$session = $request->hasSession() ? $request->getSession() : null;
|
||||||
|
|
||||||
@ -84,11 +84,11 @@ class ContextListener implements ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* Writes the SecurityContext to the session.
|
* 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +104,7 @@ class ContextListener implements ListenerInterface
|
|||||||
$this->logger->debug('Write SecurityContext in the session');
|
$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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Component\Security\Core\SecurityContextInterface;
|
|||||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
use Symfony\Component\Security\Http\EntryPoint\DigestAuthenticationEntryPoint;
|
use Symfony\Component\Security\Http\EntryPoint\DigestAuthenticationEntryPoint;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
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\HttpKernel\Events;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||||
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||||
@ -54,11 +54,11 @@ class DigestAuthenticationListener implements ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* Handles digest authentication.
|
* 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')) {
|
if (!$header = $request->server->get('PHP_AUTH_DIGEST')) {
|
||||||
return;
|
return;
|
||||||
@ -79,7 +79,7 @@ class DigestAuthenticationListener implements ListenerInterface
|
|||||||
try {
|
try {
|
||||||
$digestAuth->validateAndDecode($this->authenticationEntryPoint->getKey(), $this->authenticationEntryPoint->getRealmName());
|
$digestAuth->validateAndDecode($this->authenticationEntryPoint->getKey(), $this->authenticationEntryPoint->getRealmName());
|
||||||
} catch (BadCredentialsException $e) {
|
} catch (BadCredentialsException $e) {
|
||||||
$this->fail($eventArgs, $request, $e);
|
$this->fail($event, $request, $e);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ class DigestAuthenticationListener implements ListenerInterface
|
|||||||
|
|
||||||
$serverDigestMd5 = $digestAuth->calculateServerDigest($user->getPassword(), $request->getMethod());
|
$serverDigestMd5 = $digestAuth->calculateServerDigest($user->getPassword(), $request->getMethod());
|
||||||
} catch (UsernameNotFoundException $notFound) {
|
} 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;
|
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->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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($digestAuth->isNonceExpired()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ class DigestAuthenticationListener implements ListenerInterface
|
|||||||
$this->securityContext->setToken(new UsernamePasswordToken($user, $user->getPassword(), $this->providerKey));
|
$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);
|
$this->securityContext->setToken(null);
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ class DigestAuthenticationListener implements ListenerInterface
|
|||||||
$this->logger->debug($authException);
|
$this->logger->debug($authException);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->authenticationEntryPoint->start($eventArgs, $request, $authException);
|
$this->authenticationEntryPoint->start($event, $request, $authException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ use Symfony\Component\Security\Core\Exception\InsufficientAuthenticationExceptio
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Events;
|
use Symfony\Component\HttpKernel\Events;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExceptionListener catches authentication exception and converts them to
|
* ExceptionListener catches authentication exception and converts them to
|
||||||
@ -54,22 +54,22 @@ class ExceptionListener
|
|||||||
/**
|
/**
|
||||||
* Registers a onCoreException listener to take care of security exceptions.
|
* 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.
|
* 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();
|
$exception = $event->getException();
|
||||||
$request = $eventArgs->getRequest();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
if ($exception instanceof AuthenticationException) {
|
if ($exception instanceof AuthenticationException) {
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
@ -77,9 +77,9 @@ class ExceptionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$response = $this->startAuthentication($eventArgs, $request, $exception);
|
$response = $this->startAuthentication($event, $request, $exception);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$eventArgs->set('exception', $e);
|
$event->set('exception', $e);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -91,9 +91,9 @@ class ExceptionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
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) {
|
} catch (\Exception $e) {
|
||||||
$eventArgs->set('exception', $e);
|
$event->set('exception', $e);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ class ExceptionListener
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (null !== $this->accessDeniedHandler) {
|
if (null !== $this->accessDeniedHandler) {
|
||||||
$response = $this->accessDeniedHandler->handle($eventArgs, $request, $exception);
|
$response = $this->accessDeniedHandler->handle($event, $request, $exception);
|
||||||
|
|
||||||
if (!$response instanceof Response) {
|
if (!$response instanceof Response) {
|
||||||
return;
|
return;
|
||||||
@ -117,7 +117,7 @@ class ExceptionListener
|
|||||||
$subRequest = Request::create($this->errorPage);
|
$subRequest = Request::create($this->errorPage);
|
||||||
$subRequest->attributes->set(SecurityContextInterface::ACCESS_DENIED_ERROR, $exception);
|
$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);
|
$response->setStatusCode(403);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} 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()));
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
@ -134,10 +134,10 @@ class ExceptionListener
|
|||||||
return;
|
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);
|
$this->context->setToken(null);
|
||||||
|
|
||||||
@ -154,6 +154,6 @@ class ExceptionListener
|
|||||||
$request->getSession()->set('_security.target_path', $request->getUri());
|
$request->getSession()->set('_security.target_path', $request->getUri());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->authenticationEntryPoint->start($eventArgs, $request, $authException);
|
return $this->authenticationEntryPoint->start($event, $request, $authException);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Security\Http\Firewall;
|
namespace Symfony\Component\Security\Http\Firewall;
|
||||||
|
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface that must be implemented by firewall listeners
|
* Interface that must be implemented by firewall listeners
|
||||||
@ -24,7 +24,7 @@ interface ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* This interface must be implemented by firewall listeners.
|
* This interface must be implemented by firewall listeners.
|
||||||
*
|
*
|
||||||
* @param GetResponseEventArgs $eventArgs
|
* @param GetResponseEvent $event
|
||||||
*/
|
*/
|
||||||
function onCoreSecurity(GetResponseEventArgs $eventArgs);
|
function onCoreSecurity(GetResponseEvent $event);
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
|
|||||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||||
use Symfony\Component\Kernel\Event\GetResponseEventArgs;
|
use Symfony\Component\Kernel\Event\GetResponseEvent;
|
||||||
use Symfony\Component\Kernel\Events;
|
use Symfony\Component\Kernel\Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,18 +63,18 @@ class LogoutListener implements ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* Performs the logout if requested
|
* 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()) {
|
if ($this->logoutPath !== $request->getPathInfo()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->successHandler) {
|
if (null !== $this->successHandler) {
|
||||||
$response = $this->successHandler->onLogoutSuccess($eventArgs, $request);
|
$response = $this->successHandler->onLogoutSuccess($event, $request);
|
||||||
|
|
||||||
if (!$response instanceof Response) {
|
if (!$response instanceof Response) {
|
||||||
throw new \RuntimeException('Logout Success Handler did not return a Response.');
|
throw new \RuntimeException('Logout Success Handler did not return a Response.');
|
||||||
|
@ -4,8 +4,8 @@ namespace Symfony\Component\Security\Http\Firewall;
|
|||||||
|
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\Events as KernelEvents;
|
use Symfony\Component\HttpKernel\Events as KernelEvents;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
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\Exception\CookieTheftException;
|
||||||
use Symfony\Component\Security\Core\SecurityContext;
|
use Symfony\Component\Security\Core\SecurityContext;
|
||||||
use Symfony\Component\Security\Http\RememberMe\RememberMeServicesInterface;
|
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 Symfony\Component\Security\Http\Events;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the Symfony framework.
|
* This file is part of the Symfony framework.
|
||||||
@ -38,7 +38,7 @@ class RememberMeListener implements ListenerInterface
|
|||||||
private $rememberMeServices;
|
private $rememberMeServices;
|
||||||
private $authenticationManager;
|
private $authenticationManager;
|
||||||
private $logger;
|
private $logger;
|
||||||
private $evm;
|
private $dispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -48,27 +48,27 @@ class RememberMeListener implements ListenerInterface
|
|||||||
* @param AuthenticationManagerInterface $authenticationManager
|
* @param AuthenticationManagerInterface $authenticationManager
|
||||||
* @param LoggerInterface $logger
|
* @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->securityContext = $securityContext;
|
||||||
$this->rememberMeServices = $rememberMeServices;
|
$this->rememberMeServices = $rememberMeServices;
|
||||||
$this->authenticationManager = $authenticationManager;
|
$this->authenticationManager = $authenticationManager;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->evm = $evm;
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles remember-me cookie based authentication.
|
* 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()) {
|
if (null !== $this->securityContext->getToken()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = $eventArgs->getRequest();
|
$request = $event->getRequest();
|
||||||
if (null === $token = $this->rememberMeServices->autoLogin($request)) {
|
if (null === $token = $this->rememberMeServices->autoLogin($request)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -77,9 +77,9 @@ class RememberMeListener implements ListenerInterface
|
|||||||
$token = $this->authenticationManager->authenticate($token);
|
$token = $this->authenticationManager->authenticate($token);
|
||||||
$this->securityContext->setToken($token);
|
$this->securityContext->setToken($token);
|
||||||
|
|
||||||
if (null !== $this->evm) {
|
if (null !== $this->dispatcher) {
|
||||||
$loginEventArgs = new InteractiveLoginEventArgs($request, $token);
|
$loginEvent = new InteractiveLoginEvent($request, $token);
|
||||||
$this->evm->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEventArgs);
|
$this->dispatcher->dispatchEvent(Events::onSecurityInteractiveLogin, $loginEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->logger) {
|
if (null !== $this->logger) {
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
|||||||
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
||||||
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface;
|
||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
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\HttpKernel\Events;
|
||||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
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\Authentication\Token\UsernamePasswordToken;
|
||||||
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
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 Symfony\Component\Security\Http\Events;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SwitchUserListener allows a user to impersonate another one temporarily
|
* SwitchUserListener allows a user to impersonate another one temporarily
|
||||||
@ -46,12 +46,12 @@ class SwitchUserListener implements ListenerInterface
|
|||||||
private $usernameParameter;
|
private $usernameParameter;
|
||||||
private $role;
|
private $role;
|
||||||
private $logger;
|
private $logger;
|
||||||
private $evm;
|
private $dispatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* 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)) {
|
if (empty($providerKey)) {
|
||||||
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
throw new \InvalidArgumentException('$providerKey must not be empty.');
|
||||||
@ -65,17 +65,17 @@ class SwitchUserListener implements ListenerInterface
|
|||||||
$this->usernameParameter = $usernameParameter;
|
$this->usernameParameter = $usernameParameter;
|
||||||
$this->role = $role;
|
$this->role = $role;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->evm = $evm;
|
$this->dispatcher = $dispatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles digest authentication.
|
* 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)) {
|
if (!$request->get($this->usernameParameter)) {
|
||||||
return;
|
return;
|
||||||
@ -129,9 +129,9 @@ class SwitchUserListener implements ListenerInterface
|
|||||||
|
|
||||||
$token = new UsernamePasswordToken($user, $user->getPassword(), $this->providerKey, $roles);
|
$token = new UsernamePasswordToken($user, $user->getPassword(), $this->providerKey, $roles);
|
||||||
|
|
||||||
if (null !== $this->evm) {
|
if (null !== $this->dispatcher) {
|
||||||
$switchEventArgs = new SwitchUserEventArgs($request, $token->getUser());
|
$switchEvent = new SwitchUserEvent($request, $token->getUser());
|
||||||
$this->evm->dispatchEvent(Events::onSecuritySwitchUser, $switchEventArgs);
|
$this->dispatcher->dispatchEvent(Events::onSecuritySwitchUser, $switchEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $token;
|
return $token;
|
||||||
@ -150,9 +150,9 @@ class SwitchUserListener implements ListenerInterface
|
|||||||
throw new AuthenticationCredentialsNotFoundException(sprintf('Could not find original Token object.'));
|
throw new AuthenticationCredentialsNotFoundException(sprintf('Could not find original Token object.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null !== $this->evm) {
|
if (null !== $this->dispatcher) {
|
||||||
$switchEventArgs = new SwitchUserEventArgs($request, $original->getUser());
|
$switchEvent = new SwitchUserEvent($request, $original->getUser());
|
||||||
$this->evm->notify(Events::onSecuritySwitchUser, $switchEventArgs);
|
$this->dispatcher->notify(Events::onSecuritySwitchUser, $switchEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $original;
|
return $original;
|
||||||
|
@ -21,7 +21,7 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterfac
|
|||||||
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
||||||
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
|
use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException;
|
||||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UsernamePasswordFormAuthenticationListener is the default implementation of
|
* UsernamePasswordFormAuthenticationListener is the default implementation of
|
||||||
@ -36,7 +36,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@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(
|
parent::__construct($securityContext, $authenticationManager, $sessionStrategy, $providerKey, array_merge(array(
|
||||||
'username_parameter' => '_username',
|
'username_parameter' => '_username',
|
||||||
@ -44,7 +44,7 @@ class UsernamePasswordFormAuthenticationListener extends AbstractAuthenticationL
|
|||||||
'csrf_parameter' => '_csrf_token',
|
'csrf_parameter' => '_csrf_token',
|
||||||
'csrf_page_id' => 'form_login',
|
'csrf_page_id' => 'form_login',
|
||||||
'post_only' => true,
|
'post_only' => true,
|
||||||
), $options), $successHandler, $failureHandler, $logger, $evm);
|
), $options), $successHandler, $failureHandler, $logger, $dispatcher);
|
||||||
|
|
||||||
$this->csrfProvider = $csrfProvider;
|
$this->csrfProvider = $csrfProvider;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterfac
|
|||||||
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
use Symfony\Component\HttpKernel\Log\LoggerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* X509 authentication listener.
|
* X509 authentication listener.
|
||||||
@ -28,9 +28,9 @@ class X509AuthenticationListener extends AbstractPreAuthenticatedListener
|
|||||||
protected $userKey;
|
protected $userKey;
|
||||||
protected $credentialKey;
|
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->userKey = $userKey;
|
||||||
$this->credentialKey = $credentialKey;
|
$this->credentialKey = $credentialKey;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace Symfony\Component\Security\Http\Logout;
|
namespace Symfony\Component\Security\Http\Logout;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Event\GetResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LogoutSuccesshandlerInterface.
|
* LogoutSuccesshandlerInterface.
|
||||||
@ -21,9 +21,9 @@ interface LogoutSuccessHandlerInterface
|
|||||||
/**
|
/**
|
||||||
* Creates a Response object to send upon a successful logout.
|
* Creates a Response object to send upon a successful logout.
|
||||||
*
|
*
|
||||||
* @param GetResponseEventArgs $eventArgs
|
* @param GetResponseEvent $event
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return Response never null
|
* @return Response never null
|
||||||
*/
|
*/
|
||||||
function onLogoutSuccess(GetResponseEventArgs $eventArgs, Request $request);
|
function onLogoutSuccess(GetResponseEvent $event, Request $request);
|
||||||
}
|
}
|
@ -14,16 +14,15 @@ namespace Symfony\Tests\Component\HttpKernel\DataCollector;
|
|||||||
use Symfony\Component\HttpKernel\DataCollector\EventDataCollector;
|
use Symfony\Component\HttpKernel\DataCollector\EventDataCollector;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Debug\TraceableEventManagerInterface;
|
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcherInterface;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
|
|
||||||
class EventDataCollectorTest extends \PHPUnit_Framework_TestCase
|
class EventDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testCollect()
|
public function testCollect()
|
||||||
{
|
{
|
||||||
$c = new EventDataCollector();
|
$c = new EventDataCollector();
|
||||||
$c->setEventManager(new TestEventManager());
|
$c->setEventDispatcher(new TestEventDispatcher());
|
||||||
|
|
||||||
$c->collect(new Request(), new Response());
|
$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()
|
function getCalledListeners()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|||||||
use Symfony\Component\HttpKernel\Debug\ExceptionListener;
|
use Symfony\Component\HttpKernel\Debug\ExceptionListener;
|
||||||
use Symfony\Component\HttpKernel\Debug\ErrorException;
|
use Symfony\Component\HttpKernel\Debug\ErrorException;
|
||||||
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
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\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Tests\Component\HttpKernel\Logger;
|
use Symfony\Tests\Component\HttpKernel\Logger;
|
||||||
@ -44,19 +44,19 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider provider
|
* @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
|
//store the current error_log, and set the new one to dev/null
|
||||||
$error_log = ini_get('error_log');
|
$error_log = ini_get('error_log');
|
||||||
ini_set('error_log', '/dev/null');
|
ini_set('error_log', '/dev/null');
|
||||||
|
|
||||||
$l = new ExceptionListener('foo');
|
$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 {
|
try {
|
||||||
$l->onCoreException($eventArgs2);
|
$l->onCoreException($event2);
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
$this->assertSame('foo', $e->getMessage());
|
$this->assertSame('foo', $e->getMessage());
|
||||||
}
|
}
|
||||||
@ -68,17 +68,17 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider provider
|
* @dataProvider provider
|
||||||
*/
|
*/
|
||||||
public function testHandleWithLogger($eventArgs, $eventArgs2)
|
public function testHandleWithLogger($event, $event2)
|
||||||
{
|
{
|
||||||
$logger = new TestLogger();
|
$logger = new TestLogger();
|
||||||
|
|
||||||
$l = new ExceptionListener('foo', $logger);
|
$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 {
|
try {
|
||||||
$l->onCoreException($eventArgs2);
|
$l->onCoreException($event2);
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
$this->assertSame('foo', $e->getMessage());
|
$this->assertSame('foo', $e->getMessage());
|
||||||
}
|
}
|
||||||
@ -91,11 +91,11 @@ class ExceptionListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$request = new Request();
|
$request = new Request();
|
||||||
$exception = new ErrorException('foo');
|
$exception = new ErrorException('foo');
|
||||||
$eventArgs = new GetResponseForExceptionEventArgs(new TestKernel(), $request, 'foo', $exception);
|
$event = new GetResponseForExceptionEvent(new TestKernel(), $request, 'foo', $exception);
|
||||||
$eventArgs2 = new GetResponseForExceptionEventArgs(new TestKernelThatThrowsException(), $request, 'foo', $exception);
|
$event2 = new GetResponseForExceptionEvent(new TestKernelThatThrowsException(), $request, 'foo', $exception);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
array($eventArgs, $eventArgs2)
|
array($event, $event2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,54 +13,54 @@ namespace Symfony\Tests\Component\HttpKernel\HttpCache;
|
|||||||
|
|
||||||
use Symfony\Component\HttpKernel\HttpCache\Esi;
|
use Symfony\Component\HttpKernel\HttpCache\Esi;
|
||||||
use Symfony\Component\HttpKernel\HttpCache\EsiListener;
|
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\Events;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
class EsiListenerTest extends \PHPUnit_Framework_TestCase
|
class EsiListenerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function testFilterDoesNothingForSubRequests()
|
public function testFilterDoesNothingForSubRequests()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||||
$response = new Response('foo <esi:include src="" />');
|
$response = new Response('foo <esi:include src="" />');
|
||||||
$listener = new EsiListener(new Esi());
|
$listener = new EsiListener(new Esi());
|
||||||
|
|
||||||
$evm->addEventListener(Events::filterCoreResponse, $listener);
|
$dispatcher->addEventListener(Events::filterCoreResponse, $listener);
|
||||||
$eventArgs = new FilterResponseEventArgs($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
|
$event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
|
||||||
$evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
|
$dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
|
||||||
|
|
||||||
$this->assertEquals('', $eventArgs->getResponse()->headers->get('Surrogate-Control'));
|
$this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFilterWhenThereIsSomeEsiIncludes()
|
public function testFilterWhenThereIsSomeEsiIncludes()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||||
$response = new Response('foo <esi:include src="" />');
|
$response = new Response('foo <esi:include src="" />');
|
||||||
$listener = new EsiListener(new Esi());
|
$listener = new EsiListener(new Esi());
|
||||||
|
|
||||||
$evm->addEventListener(Events::filterCoreResponse, $listener);
|
$dispatcher->addEventListener(Events::filterCoreResponse, $listener);
|
||||||
$eventArgs = new FilterResponseEventArgs($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
|
$event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
|
||||||
$evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
|
$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()
|
public function testFilterWhenThereIsNoEsiIncludes()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||||
$response = new Response('foo');
|
$response = new Response('foo');
|
||||||
$listener = new EsiListener(new Esi());
|
$listener = new EsiListener(new Esi());
|
||||||
|
|
||||||
$evm->addEventListener(Events::filterCoreResponse, $listener);
|
$dispatcher->addEventListener(Events::filterCoreResponse, $listener);
|
||||||
$eventArgs = new FilterResponseEventArgs($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
|
$event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
|
||||||
$evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
|
$dispatcher->dispatchEvent(Events::filterCoreResponse, $event);
|
||||||
|
|
||||||
$this->assertEquals('', $eventArgs->getResponse()->headers->get('Surrogate-Control'));
|
$this->assertEquals('', $event->getResponse()->headers->get('Surrogate-Control'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
class TestHttpKernel extends HttpKernel implements ControllerResolverInterface
|
class TestHttpKernel extends HttpKernel implements ControllerResolverInterface
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ class TestHttpKernel extends HttpKernel implements ControllerResolverInterface
|
|||||||
$this->called = false;
|
$this->called = false;
|
||||||
$this->catch = 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)
|
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false)
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface
|
class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInterface
|
||||||
{
|
{
|
||||||
@ -39,7 +39,7 @@ class TestMultipleHttpKernel extends HttpKernel implements ControllerResolverInt
|
|||||||
$this->headers[] = $response['headers'];
|
$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)
|
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = false)
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
|||||||
use Symfony\Component\HttpKernel\Events;
|
use Symfony\Component\HttpKernel\Events;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
@ -25,7 +25,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testHandleWhenControllerThrowsAnExceptionAndRawIsTrue()
|
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);
|
$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, true);
|
||||||
}
|
}
|
||||||
@ -35,33 +35,33 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalseAndNoListenerIsRegistered()
|
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);
|
$kernel->handle(new Request(), HttpKernelInterface::MASTER_REQUEST, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse()
|
public function testHandleWhenControllerThrowsAnExceptionAndRawIsFalse()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$evm->addEventListener(Events::onCoreException, function ($eventArgs)
|
$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());
|
$this->assertEquals('foo', $kernel->handle(new Request())->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHandleWhenAListenerReturnsAResponse()
|
public function testHandleWhenAListenerReturnsAResponse()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$evm->addEventListener(Events::onCoreRequest, function ($eventArgs)
|
$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());
|
$this->assertEquals('hello', $kernel->handle(new Request())->getContent());
|
||||||
}
|
}
|
||||||
@ -71,8 +71,8 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testHandleWhenNoControllerIsFound()
|
public function testHandleWhenNoControllerIsFound()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$kernel = new HttpKernel($evm, $this->getResolver(false));
|
$kernel = new HttpKernel($dispatcher, $this->getResolver(false));
|
||||||
|
|
||||||
$kernel->handle(new Request());
|
$kernel->handle(new Request());
|
||||||
}
|
}
|
||||||
@ -82,8 +82,8 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testHandleWhenNoControllerIsNotACallable()
|
public function testHandleWhenNoControllerIsNotACallable()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$kernel = new HttpKernel($evm, $this->getResolver('foobar'));
|
$kernel = new HttpKernel($dispatcher, $this->getResolver('foobar'));
|
||||||
|
|
||||||
$kernel->handle(new Request());
|
$kernel->handle(new Request());
|
||||||
}
|
}
|
||||||
@ -93,32 +93,32 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testHandleWhenControllerDoesNotReturnAResponse()
|
public function testHandleWhenControllerDoesNotReturnAResponse()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$kernel = new HttpKernel($evm, $this->getResolver(function () { return 'foo'; }));
|
$kernel = new HttpKernel($dispatcher, $this->getResolver(function () { return 'foo'; }));
|
||||||
|
|
||||||
$kernel->handle(new Request());
|
$kernel->handle(new Request());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHandleWhenControllerDoesNotReturnAResponseButAViewIsRegistered()
|
public function testHandleWhenControllerDoesNotReturnAResponseButAViewIsRegistered()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$evm->addEventListener(Events::onCoreView, function ($eventArgs)
|
$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());
|
$this->assertEquals('foo', $kernel->handle(new Request())->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testHandleWithAResponseListener()
|
public function testHandleWithAResponseListener()
|
||||||
{
|
{
|
||||||
$evm = new EventManager();
|
$dispatcher = new EventDispatcher();
|
||||||
$evm->addEventListener(Events::filterCoreResponse, function ($eventArgs)
|
$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());
|
$this->assertEquals('foo', $kernel->handle(new Request())->getContent());
|
||||||
}
|
}
|
||||||
|
@ -15,21 +15,21 @@ use Symfony\Component\HttpKernel\ResponseListener;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Event\FilterResponseEventArgs;
|
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||||
use Symfony\Component\HttpKernel\Events;
|
use Symfony\Component\HttpKernel\Events;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
private $evm;
|
private $dispatcher;
|
||||||
|
|
||||||
private $kernel;
|
private $kernel;
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->evm = new EventManager();
|
$this->dispatcher = new EventDispatcher();
|
||||||
$listener = new ResponseListener('UTF-8');
|
$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');
|
$this->kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||||
|
|
||||||
@ -38,10 +38,10 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$response = new Response('foo');
|
$response = new Response('foo');
|
||||||
|
|
||||||
$eventArgs = new FilterResponseEventArgs($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
|
$event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
|
||||||
$this->evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
|
$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()
|
public function testFilterDoesNothingIfContentTypeIsSet()
|
||||||
@ -49,20 +49,20 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$response = new Response('foo');
|
$response = new Response('foo');
|
||||||
$response->headers->set('Content-Type', 'text/plain');
|
$response->headers->set('Content-Type', 'text/plain');
|
||||||
|
|
||||||
$eventArgs = new FilterResponseEventArgs($this->kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
|
$event = new FilterResponseEvent($this->kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
|
||||||
$this->evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
|
$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()
|
public function testFilterDoesNothingIfRequestFormatIsNotDefined()
|
||||||
{
|
{
|
||||||
$response = new Response('foo');
|
$response = new Response('foo');
|
||||||
|
|
||||||
$eventArgs = new FilterResponseEventArgs($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
|
$event = new FilterResponseEvent($this->kernel, Request::create('/'), HttpKernelInterface::MASTER_REQUEST, $response);
|
||||||
$this->evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
|
$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()
|
public function testFilterSetContentType()
|
||||||
@ -71,9 +71,9 @@ class ResponseListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$request = Request::create('/');
|
$request = Request::create('/');
|
||||||
$request->setRequestFormat('json');
|
$request->setRequestFormat('json');
|
||||||
|
|
||||||
$eventArgs = new FilterResponseEventArgs($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
|
$event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
|
||||||
$this->evm->dispatchEvent(Events::filterCoreResponse, $eventArgs);
|
$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'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,13 +15,13 @@ use Symfony\Component\HttpKernel\HttpKernel;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
|
||||||
use Doctrine\Common\EventManager;
|
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||||
|
|
||||||
class TestHttpKernel extends HttpKernel implements ControllerResolverInterface
|
class TestHttpKernel extends HttpKernel implements ControllerResolverInterface
|
||||||
{
|
{
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct(new EventManager(), $this);
|
parent::__construct(new EventDispatcher(), $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getController(Request $request)
|
public function getController(Request $request)
|
||||||
|
@ -135,12 +135,12 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function getGetResponseEvent()
|
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()
|
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()
|
protected function getListener()
|
||||||
|
Reference in New Issue
Block a user