6f02a7fd73d23cd407dc62120c26cdd40db8801d
[yaffs-website] / vendor / symfony / http-foundation / Session / Storage / PhpBridgeSessionStorage.php
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 use Symfony\Component\HttpFoundation\Session\Storage\Proxy\AbstractProxy;
15 use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
16
17 /**
18  * Allows session to be started by PHP and managed by Symfony.
19  *
20  * @author Drak <drak@zikula.org>
21  */
22 class PhpBridgeSessionStorage extends NativeSessionStorage
23 {
24     /**
25      * Constructor.
26      *
27      * @param AbstractProxy|NativeSessionHandler|\SessionHandlerInterface|null $handler
28      * @param MetadataBag                                                      $metaBag MetadataBag
29      */
30     public function __construct($handler = null, MetadataBag $metaBag = null)
31     {
32         $this->setMetadataBag($metaBag);
33         $this->setSaveHandler($handler);
34     }
35
36     /**
37      * {@inheritdoc}
38      */
39     public function start()
40     {
41         if ($this->started) {
42             return true;
43         }
44
45         $this->loadSession();
46
47         return true;
48     }
49
50     /**
51      * {@inheritdoc}
52      */
53     public function clear()
54     {
55         // clear out the bags and nothing else that may be set
56         // since the purpose of this driver is to share a handler
57         foreach ($this->bags as $bag) {
58             $bag->clear();
59         }
60
61         // reconnect the bags to the session
62         $this->loadSession();
63     }
64 }