Handler
4 years ago
Proxy
4 years ago
MetadataBag.php
4 years ago
MockArraySessionStorage.php
4 years ago
MockFileSessionStorage.php
4 years ago
NativeSessionStorage.php
4 years ago
PhpBridgeSessionStorage.php
4 years ago
SessionStorageInterface.php
4 years ago
PhpBridgeSessionStorage.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | * This file is part of the Symfony package. |
| 5 | * |
| 6 | * (c) Fabien Potencier <fabien@symfony.com> |
| 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; |
| 13 | |
| 14 | /** |
| 15 | * Allows session to be started by PHP and managed by Symfony. |
| 16 | * |
| 17 | * @author Drak <drak@zikula.org> |
| 18 | */ |
| 19 | class PhpBridgeSessionStorage extends NativeSessionStorage |
| 20 | { |
| 21 | /** |
| 22 | * @param \SessionHandlerInterface|null $handler |
| 23 | * @param MetadataBag $metaBag MetadataBag |
| 24 | */ |
| 25 | public function __construct($handler = null, MetadataBag $metaBag = null) |
| 26 | { |
| 27 | if (!\extension_loaded('session')) { |
| 28 | throw new \LogicException('PHP extension "session" is required.'); |
| 29 | } |
| 30 | |
| 31 | $this->setMetadataBag($metaBag); |
| 32 | $this->setSaveHandler($handler); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * {@inheritdoc} |
| 37 | */ |
| 38 | public function start() |
| 39 | { |
| 40 | if ($this->started) { |
| 41 | return true; |
| 42 | } |
| 43 | |
| 44 | $this->loadSession(); |
| 45 | |
| 46 | return true; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * {@inheritdoc} |
| 51 | */ |
| 52 | public function clear() |
| 53 | { |
| 54 | // clear out the bags and nothing else that may be set |
| 55 | // since the purpose of this driver is to share a handler |
| 56 | foreach ($this->bags as $bag) { |
| 57 | $bag->clear(); |
| 58 | } |
| 59 | |
| 60 | // reconnect the bags to the session |
| 61 | $this->loadSession(); |
| 62 | } |
| 63 | } |
| 64 |