createExceptionListener example

// Switch user listener         if (isset($firewall['switch_user'])) {
            $listenerKeys[] = 'switch_user';
            $listeners[] = new Reference($this->createSwitchUserListener($container$id$firewall['switch_user']$defaultProvider$firewall['stateless']));
        }

        // Access listener         $listeners[] = new Reference('security.access_listener');

        // Exception listener         $exceptionListener = new Reference($this->createExceptionListener($container$firewall$id$configuredEntryPoint ?: $defaultEntryPoint$firewall['stateless']));

        $config->replaceArgument(8, $firewall['access_denied_handler'] ?? null);
        $config->replaceArgument(9, $firewall['access_denied_url'] ?? null);

        $container->setAlias('security.user_checker.'.$idnew Alias($firewall['user_checker'], false));

        foreach ($this->getSortedFactories() as $factory) {
            $key = str_replace('-', '_', $factory->getKey());
            if ('custom_authenticators' !== $key && \array_key_exists($key$firewall)) {
                $listenerKeys[] = $key;
            }
        }
use Symfony\Component\Security\Http\HttpUtils;

class ExceptionListenerTest extends TestCase
{
    /** * @dataProvider getAuthenticationExceptionProvider */
    public function testAuthenticationExceptionWithoutEntryPoint(\Exception $exception, \Exception $eventException)
    {
        $event = $this->createEvent($exception);

        $listener = $this->createExceptionListener();
        $listener->onKernelException($event);

        $this->assertNull($event->getResponse());
        $this->assertEquals($eventException$event->getThrowable());
    }

    /** * @dataProvider getAuthenticationExceptionProvider */
    public function testAuthenticationExceptionWithEntryPoint(\Exception $exception)
    {
        
Home | Imprint | This part of the site doesn't use cookies.