Added the Search API Synonym module to deal specifically with licence and license...
[yaffs-website] / vendor / symfony / http-foundation / Session / Storage / Proxy / AbstractProxy.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\Proxy;
13
14 /**
15  * @author Drak <drak@zikula.org>
16  */
17 abstract class AbstractProxy
18 {
19     /**
20      * Flag if handler wraps an internal PHP session handler (using \SessionHandler).
21      *
22      * @var bool
23      */
24     protected $wrapper = false;
25
26     /**
27      * @var string
28      */
29     protected $saveHandlerName;
30
31     /**
32      * Gets the session.save_handler name.
33      *
34      * @return string
35      */
36     public function getSaveHandlerName()
37     {
38         return $this->saveHandlerName;
39     }
40
41     /**
42      * Is this proxy handler and instance of \SessionHandlerInterface.
43      *
44      * @return bool
45      */
46     public function isSessionHandlerInterface()
47     {
48         return $this instanceof \SessionHandlerInterface;
49     }
50
51     /**
52      * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
53      *
54      * @return bool
55      */
56     public function isWrapper()
57     {
58         return $this->wrapper;
59     }
60
61     /**
62      * Has a session started?
63      *
64      * @return bool
65      */
66     public function isActive()
67     {
68         return \PHP_SESSION_ACTIVE === session_status();
69     }
70
71     /**
72      * Gets the session ID.
73      *
74      * @return string
75      */
76     public function getId()
77     {
78         return session_id();
79     }
80
81     /**
82      * Sets the session ID.
83      *
84      * @param string $id
85      *
86      * @throws \LogicException
87      */
88     public function setId($id)
89     {
90         if ($this->isActive()) {
91             throw new \LogicException('Cannot change the ID of an active session');
92         }
93
94         session_id($id);
95     }
96
97     /**
98      * Gets the session name.
99      *
100      * @return string
101      */
102     public function getName()
103     {
104         return session_name();
105     }
106
107     /**
108      * Sets the session name.
109      *
110      * @param string $name
111      *
112      * @throws \LogicException
113      */
114     public function setName($name)
115     {
116         if ($this->isActive()) {
117             throw new \LogicException('Cannot change the name of an active session');
118         }
119
120         session_name($name);
121     }
122 }