* * 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:----QROfBrXIaDM6EEcdmoDHe/tPP738pxA/H2xL7ARbI3Og4lDedZbEFtHrBWs6P8gFJrfFFhyO4abfKdo5S2gxIm0rdkATdifkwYgLnwSX5ZvaZk++1R0WzMnuux0dGs2I9LoZ3TplS4o4QBfagFRvNuDAzEbdKiiWDwDt52cYmdFibc85eSwTi4WAcm9WM4rfpedva24UIevsM+rS+TAvloA5ORfc/owPZbGkireocwqQrkcMpRVK8IDe3KAidzTffKraZ1MrtPYPjGYnpwH0huCHLCUs6ulViwhh+7w/uyb0uRESzqqQi7E8GV+R4jag+w/i83bj4ol4ysdqPVZJmacC/ImH0aaEp7us0WFzQV7FemNUckcpJkYxoRBD9FhmmGxoG8ePDHMAG2xlMgEI7n9T0l771QeQh8CG7ftFl8/RRFkgF6Ygyo9VBg8YCftY2eKfZqXLN1fiHsTJKJEPtZ6Mm/2bNrTQKo8mQ+cgXXQcnAaLRbuPog0MGwqgUTBu+60VATYUm2Q67RM9L2vu34LUpmh9HIfsi0CWtr1NOk6P4SFieQp2EkpH7Rrg74yCGHLCqBM9c9HA9nDSSnqZVqCwU4TAad7DG36xYONz/ulo5e3gqRAZ8vTgJ6eta0hg03ofSamVUAnzoiFMzJa5IW2nwgE2brZu07AWo/iEcJU=----ATTACHMENT:----Mzc3NDA4NTcwNTQ2NTk3OSA2NDM2ODgzMTM2NDYzNjI1IDc1NzY3MjEwNjk1NDY2NDQ=