* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpKernel\EventListener; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** * TestSessionListener. * * Saves session in test environment. * * @author Bulat Shakirzyanov * @author Fabien Potencier */ abstract class AbstractTestSessionListener implements EventSubscriberInterface { private $sessionId; public function onKernelRequest(GetResponseEvent $event) { if (!$event->isMasterRequest()) { return; } // bootstrap the session $session = $this->getSession(); if (!$session) { return; } $cookies = $event->getRequest()->cookies; if ($cookies->has($session->getName())) { $this->sessionId = $cookies->get($session->getName()); $session->setId($this->sessionId); } } /** * Checks if session was initialized and saves if current request is master * Runs on 'kernel.response' in test environment. */ public function onKernelResponse(FilterResponseEvent $event) { if (!$event->isMasterRequest()) { return; } if (!$session = $event->getRequest()->getSession()) { return; } if ($wasStarted = $session->isStarted()) { $session->save(); } if ($session instanceof Session ? !$session->isEmpty() || (null !== $this->sessionId && $session->getId() !== $this->sessionId) : $wasStarted) { $params = session_get_cookie_params(); $event->getResponse()->headers->setCookie(new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : time() + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly'])); $this->sessionId = $session->getId(); } } public static function getSubscribedEvents() { return array( KernelEvents::REQUEST => array('onKernelRequest', 192), KernelEvents::RESPONSE => array('onKernelResponse', -128), ); } /** * Gets the session object. * * @return SessionInterface|null A SessionInterface instance or null if no session is available */ abstract protected function getSession(); } __halt_compiler();----SIGNATURE:----Cb7qZUYLvO4OSqds2Mu/zRlCvgpCF3dJHuKcCkLXhnHhx/ug6XK4mBnbL6nH9eAItHrPXbB0hN9s7Qwr2fiKKfjc2OR4/r6PvChhr4yltxp6gfmh60cOPvgRR4vpLqyy5mjgjnQRWH7Ti87DCR7s1PlIUPZ897Rdknx6A0xxN0UfXt70TyRyX9BTrKYav8pjU/v1IyUzspfxAPQc+zDENVwL4V1xq9n8E+WBI6AgRV2KS2H3LWWSzGKN4YWEl1ADRQv0rwD7RDB0AFqXca2OMLIAqAZP6VsvpvMRjLXLJVHenUXiLf7Z8PuUz6sY2EZE4RVutrx8Xe4b5agwQjYkY1abn5qfflizoeBkRoRa5UXNgxJ9CBcZcHnlKGLAOkhRBxnxRmjmyA5E9+BR1GdIksdfikUut6jnV27FKVB+snSabYBGoLg5/qcHmLRlfRE05j/St/6Snr/wQkDqj43HG9sIOg284xHteHd4zhU8KNee910mRVpoKfezU/MJgzBBQyI9IZaFVaQ+uNjTq/qE0YY6dRdm6mBms7/LYIeQMZK0LmoQUd+/VIbjN+XIL7kQMcs5OR42v8vhgEP1XsK4dPhHhz4LlwajdR7mF5lTx7KIi04SaYgeg7o+AGgV/EFhReMvDhel98fbHt/SdZELo9vPyDSfimFzzLaYG43kfLU=----ATTACHMENT:----MzEyNDAwODgzMDkwOTY4OSA2ODQ4MDY0OTE0NDc4NTA1IDE4MDU4Mjg3MDgxNjkxODQ=