Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
TestSessionListener.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\HttpKernel\EventListener;
13
14 use Symfony\Component\HttpFoundation\Cookie;
15 use Symfony\Component\HttpKernel\KernelEvents;
16 use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
17 use Symfony\Component\HttpKernel\Event\GetResponseEvent;
18 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
19
20 /**
21 * TestSessionListener.
22 *
23 * Saves session in test environment.
24 *
25 * @author Bulat Shakirzyanov <mallluhuct@gmail.com>
26 * @author Fabien Potencier <fabien@symfony.com>
27 */
28 abstract class TestSessionListener implements EventSubscriberInterface
29 {
30 public function onKernelRequest(GetResponseEvent $event)
31 {
32 if (!$event->isMasterRequest()) {
33 return;
34 }
35
36 // bootstrap the session
37 $session = $this->getSession();
38 if (!$session) {
39 return;
40 }
41
42 $cookies = $event->getRequest()->cookies;
43
44 if ($cookies->has($session->getName())) {
45 $session->setId($cookies->get($session->getName()));
46 }
47 }
48
49 /**
50 * Checks if session was initialized and saves if current request is master
51 * Runs on 'kernel.response' in test environment.
52 *
53 * @param FilterResponseEvent $event
54 */
55 public function onKernelResponse(FilterResponseEvent $event)
56 {
57 if (!$event->isMasterRequest()) {
58 return;
59 }
60
61 $session = $event->getRequest()->getSession();
62 if ($session && $session->isStarted()) {
63 $session->save();
64 $params = session_get_cookie_params();
65 $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']));
66 }
67 }
68
69 public static function getSubscribedEvents()
70 {
71 return array(
72 KernelEvents::REQUEST => array('onKernelRequest', 192),
73 KernelEvents::RESPONSE => array('onKernelResponse', -128),
74 );
75 }
76
77 /**
78 * Gets the session object.
79 *
80 * @return SessionInterface|null A SessionInterface instance or null if no session is available
81 */
82 abstract protected function getSession();
83 }
84