wpide
/
vendor
/
symfony
/
http-foundation
/
Session
/
Storage
/
Handler
/
MarshallingSessionHandler.php
MarshallingSessionHandler.php in WPIDE – File Manager & Code Editor 3.5.10, at vendor/symfony/http-foundation/Session/Storage/Handler/MarshallingSessionHandler.php
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <[email protected]> |
| 7 | * |
| 8 | * For the full copyright and license information, please view the LICENSE |
| 9 | * file that was distributed with this source code. |
| 10 | */ |
| 11 | |
| 12 | namespace Symfony\Component\HttpFoundation\Session\Storage\Handler; |
| 13 | |
| 14 | use Symfony\Component\Cache\Marshaller\MarshallerInterface; |
| 15 | |
| 16 | /** |
| 17 | * @author Ahmed TAILOULOUTE <[email protected]> |
| 18 | */ |
| 19 | class MarshallingSessionHandler implements \SessionHandlerInterface, \SessionUpdateTimestampHandlerInterface |
| 20 | { |
| 21 | private $handler; |
| 22 | private $marshaller; |
| 23 | |
| 24 | public function __construct(AbstractSessionHandler $handler, MarshallerInterface $marshaller) |
| 25 | { |
| 26 | $this->handler = $handler; |
| 27 | $this->marshaller = $marshaller; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @return bool |
| 32 | */ |
| 33 | #[\ReturnTypeWillChange] |
| 34 | public function open($savePath, $name) |
| 35 | { |
| 36 | return $this->handler->open($savePath, $name); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * @return bool |
| 41 | */ |
| 42 | #[\ReturnTypeWillChange] |
| 43 | public function close() |
| 44 | { |
| 45 | return $this->handler->close(); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * @return bool |
| 50 | */ |
| 51 | #[\ReturnTypeWillChange] |
| 52 | public function destroy($sessionId) |
| 53 | { |
| 54 | return $this->handler->destroy($sessionId); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * @return int|false |
| 59 | */ |
| 60 | #[\ReturnTypeWillChange] |
| 61 | public function gc($maxlifetime) |
| 62 | { |
| 63 | return $this->handler->gc($maxlifetime); |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * @return string |
| 68 | */ |
| 69 | #[\ReturnTypeWillChange] |
| 70 | public function read($sessionId) |
| 71 | { |
| 72 | return $this->marshaller->unmarshall($this->handler->read($sessionId)); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * @return bool |
| 77 | */ |
| 78 | #[\ReturnTypeWillChange] |
| 79 | public function write($sessionId, $data) |
| 80 | { |
| 81 | $failed = []; |
| 82 | $marshalledData = $this->marshaller->marshall(['data' => $data], $failed); |
| 83 | |
| 84 | if (isset($failed['data'])) { |
| 85 | return false; |
| 86 | } |
| 87 | |
| 88 | return $this->handler->write($sessionId, $marshalledData['data']); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * @return bool |
| 93 | */ |
| 94 | #[\ReturnTypeWillChange] |
| 95 | public function validateId($sessionId) |
| 96 | { |
| 97 | return $this->handler->validateId($sessionId); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * @return bool |
| 102 | */ |
| 103 | #[\ReturnTypeWillChange] |
| 104 | public function updateTimestamp($sessionId, $data) |
| 105 | { |
| 106 | return $this->handler->updateTimestamp($sessionId, $data); |
| 107 | } |
| 108 | } |
| 109 |