Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/http-foundation/Session/Session.php @ 4:a9cd425dd02b
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:11:55 +0000 |
parents | 5311817fb629 |
children |
comparison
equal
deleted
inserted
replaced
3:307d7a7fd348 | 4:a9cd425dd02b |
---|---|
9 * file that was distributed with this source code. | 9 * file that was distributed with this source code. |
10 */ | 10 */ |
11 | 11 |
12 namespace Symfony\Component\HttpFoundation\Session; | 12 namespace Symfony\Component\HttpFoundation\Session; |
13 | 13 |
14 use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface; | |
15 use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; | 14 use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; |
16 use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface; | 15 use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface; |
17 use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; | 16 use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; |
18 use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | 17 use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; |
19 use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; | 18 use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; |
19 use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface; | |
20 | 20 |
21 /** | 21 /** |
22 * @author Fabien Potencier <fabien@symfony.com> | 22 * @author Fabien Potencier <fabien@symfony.com> |
23 * @author Drak <drak@zikula.org> | 23 * @author Drak <drak@zikula.org> |
24 */ | 24 */ |
26 { | 26 { |
27 protected $storage; | 27 protected $storage; |
28 | 28 |
29 private $flashName; | 29 private $flashName; |
30 private $attributeName; | 30 private $attributeName; |
31 private $data = array(); | 31 private $data = []; |
32 private $usageIndex = 0; | 32 private $usageIndex = 0; |
33 | 33 |
34 /** | 34 /** |
35 * @param SessionStorageInterface $storage A SessionStorageInterface instance | 35 * @param SessionStorageInterface $storage A SessionStorageInterface instance |
36 * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) | 36 * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) |
52 /** | 52 /** |
53 * {@inheritdoc} | 53 * {@inheritdoc} |
54 */ | 54 */ |
55 public function start() | 55 public function start() |
56 { | 56 { |
57 ++$this->usageIndex; | |
58 | |
59 return $this->storage->start(); | 57 return $this->storage->start(); |
60 } | 58 } |
61 | 59 |
62 /** | 60 /** |
63 * {@inheritdoc} | 61 * {@inheritdoc} |
138 * | 136 * |
139 * @return int The number of attributes | 137 * @return int The number of attributes |
140 */ | 138 */ |
141 public function count() | 139 public function count() |
142 { | 140 { |
143 return count($this->getAttributeBag()->all()); | 141 return \count($this->getAttributeBag()->all()); |
144 } | 142 } |
145 | 143 |
146 /** | 144 /** |
147 * @return int | 145 * @return int |
148 * | 146 * |
158 * | 156 * |
159 * @internal | 157 * @internal |
160 */ | 158 */ |
161 public function isEmpty() | 159 public function isEmpty() |
162 { | 160 { |
163 ++$this->usageIndex; | 161 if ($this->isStarted()) { |
162 ++$this->usageIndex; | |
163 } | |
164 foreach ($this->data as &$data) { | 164 foreach ($this->data as &$data) { |
165 if (!empty($data)) { | 165 if (!empty($data)) { |
166 return false; | 166 return false; |
167 } | 167 } |
168 } | 168 } |
183 /** | 183 /** |
184 * {@inheritdoc} | 184 * {@inheritdoc} |
185 */ | 185 */ |
186 public function migrate($destroy = false, $lifetime = null) | 186 public function migrate($destroy = false, $lifetime = null) |
187 { | 187 { |
188 return $this->storage->regenerate($destroy, $lifetime); | |
189 } | |
190 | |
191 /** | |
192 * {@inheritdoc} | |
193 */ | |
194 public function save() | |
195 { | |
196 $this->storage->save(); | |
197 } | |
198 | |
199 /** | |
200 * {@inheritdoc} | |
201 */ | |
202 public function getId() | |
203 { | |
204 return $this->storage->getId(); | |
205 } | |
206 | |
207 /** | |
208 * {@inheritdoc} | |
209 */ | |
210 public function setId($id) | |
211 { | |
212 if ($this->storage->getId() !== $id) { | |
213 $this->storage->setId($id); | |
214 } | |
215 } | |
216 | |
217 /** | |
218 * {@inheritdoc} | |
219 */ | |
220 public function getName() | |
221 { | |
222 return $this->storage->getName(); | |
223 } | |
224 | |
225 /** | |
226 * {@inheritdoc} | |
227 */ | |
228 public function setName($name) | |
229 { | |
230 $this->storage->setName($name); | |
231 } | |
232 | |
233 /** | |
234 * {@inheritdoc} | |
235 */ | |
236 public function getMetadataBag() | |
237 { | |
188 ++$this->usageIndex; | 238 ++$this->usageIndex; |
189 | 239 |
190 return $this->storage->regenerate($destroy, $lifetime); | |
191 } | |
192 | |
193 /** | |
194 * {@inheritdoc} | |
195 */ | |
196 public function save() | |
197 { | |
198 ++$this->usageIndex; | |
199 | |
200 $this->storage->save(); | |
201 } | |
202 | |
203 /** | |
204 * {@inheritdoc} | |
205 */ | |
206 public function getId() | |
207 { | |
208 return $this->storage->getId(); | |
209 } | |
210 | |
211 /** | |
212 * {@inheritdoc} | |
213 */ | |
214 public function setId($id) | |
215 { | |
216 $this->storage->setId($id); | |
217 } | |
218 | |
219 /** | |
220 * {@inheritdoc} | |
221 */ | |
222 public function getName() | |
223 { | |
224 return $this->storage->getName(); | |
225 } | |
226 | |
227 /** | |
228 * {@inheritdoc} | |
229 */ | |
230 public function setName($name) | |
231 { | |
232 $this->storage->setName($name); | |
233 } | |
234 | |
235 /** | |
236 * {@inheritdoc} | |
237 */ | |
238 public function getMetadataBag() | |
239 { | |
240 ++$this->usageIndex; | |
241 | |
242 return $this->storage->getMetadataBag(); | 240 return $this->storage->getMetadataBag(); |
243 } | 241 } |
244 | 242 |
245 /** | 243 /** |
246 * {@inheritdoc} | 244 * {@inheritdoc} |