Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / http-kernel / EventListener / SessionListener.php
index 2d6adfa0122d2b4d25c084f3a06dde15b044c969..39ebfd922fac67befd4d89a18cef153533ea14b2 100644 (file)
 
 namespace Symfony\Component\HttpKernel\EventListener;
 
-use Symfony\Component\HttpFoundation\Session\SessionInterface;
-use Symfony\Component\HttpKernel\Event\GetResponseEvent;
-use Symfony\Component\HttpKernel\KernelEvents;
-use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+use Psr\Container\ContainerInterface;
 
 /**
  * Sets the session in the request.
  *
- * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @final since version 3.3
  */
-abstract class SessionListener implements EventSubscriberInterface
+class SessionListener extends AbstractSessionListener
 {
-    public function onKernelRequest(GetResponseEvent $event)
+    private $container;
+
+    public function __construct(ContainerInterface $container)
     {
-        if (!$event->isMasterRequest()) {
-            return;
-        }
+        $this->container = $container;
+    }
 
-        $request = $event->getRequest();
-        $session = $this->getSession();
-        if (null === $session || $request->hasSession()) {
+    protected function getSession()
+    {
+        if (!$this->container->has('session')) {
             return;
         }
 
-        $request->setSession($session);
+        return $this->container->get('session');
     }
-
-    public static function getSubscribedEvents()
-    {
-        return array(
-            KernelEvents::REQUEST => array('onKernelRequest', 128),
-        );
-    }
-
-    /**
-     * Gets the session object.
-     *
-     * @return SessionInterface|null A SessionInterface instance or null if no session is available
-     */
-    abstract protected function getSession();
 }