Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[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 /**
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         $this->setMetadataBag($metaBag);
28         $this->setSaveHandler($handler);
29     }
30
31     /**
32      * {@inheritdoc}
33      */
34     public function start()
35     {
36         if ($this->started) {
37             return true;
38         }
39
40         $this->loadSession();
41
42         return true;
43     }
44
45     /**
46      * {@inheritdoc}
47      */
48     public function clear()
49     {
50         // clear out the bags and nothing else that may be set
51         // since the purpose of this driver is to share a handler
52         foreach ($this->bags as $bag) {
53             $bag->clear();
54         }
55
56         // reconnect the bags to the session
57         $this->loadSession();
58     }
59 }