vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php line 91

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Symfony package.
  4.  *
  5.  * (c) Fabien Potencier <fabien@symfony.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
  11. /**
  12.  * Adds basic `SessionUpdateTimestampHandlerInterface` behaviors to another `SessionHandlerInterface`.
  13.  *
  14.  * @author Nicolas Grekas <p@tchwork.com>
  15.  */
  16. class StrictSessionHandler extends AbstractSessionHandler
  17. {
  18.     private $handler;
  19.     private $doDestroy;
  20.     public function __construct(\SessionHandlerInterface $handler)
  21.     {
  22.         if ($handler instanceof \SessionUpdateTimestampHandlerInterface) {
  23.             throw new \LogicException(sprintf('"%s" is already an instance of "SessionUpdateTimestampHandlerInterface", you cannot wrap it with "%s".'get_debug_type($handler), self::class));
  24.         }
  25.         $this->handler $handler;
  26.     }
  27.     /**
  28.      * @return bool
  29.      */
  30.     public function open($savePath$sessionName)
  31.     {
  32.         parent::open($savePath$sessionName);
  33.         return $this->handler->open($savePath$sessionName);
  34.     }
  35.     /**
  36.      * {@inheritdoc}
  37.      */
  38.     protected function doRead(string $sessionId)
  39.     {
  40.         return $this->handler->read($sessionId);
  41.     }
  42.     /**
  43.      * @return bool
  44.      */
  45.     public function updateTimestamp($sessionId$data)
  46.     {
  47.         return $this->write($sessionId$data);
  48.     }
  49.     /**
  50.      * {@inheritdoc}
  51.      */
  52.     protected function doWrite(string $sessionIdstring $data)
  53.     {
  54.         return $this->handler->write($sessionId$data);
  55.     }
  56.     /**
  57.      * @return bool
  58.      */
  59.     public function destroy($sessionId)
  60.     {
  61.         $this->doDestroy true;
  62.         $destroyed parent::destroy($sessionId);
  63.         return $this->doDestroy $this->doDestroy($sessionId) : $destroyed;
  64.     }
  65.     /**
  66.      * {@inheritdoc}
  67.      */
  68.     protected function doDestroy(string $sessionId)
  69.     {
  70.         $this->doDestroy false;
  71.         return $this->handler->destroy($sessionId);
  72.     }
  73.     /**
  74.      * @return bool
  75.      */
  76.     public function close()
  77.     {
  78.         return $this->handler->close();
  79.     }
  80.     /**
  81.      * @return bool
  82.      */
  83.     public function gc($maxlifetime)
  84.     {
  85.         return $this->handler->gc($maxlifetime);
  86.     }
  87. }