comparison vendor/symfony/http-foundation/Session/Session.php @ 2:5311817fb629

Theme updates
author Chris Cannam
date Tue, 10 Jul 2018 13:19:18 +0000
parents c75dbcec494b
children a9cd425dd02b
comparison
equal deleted inserted replaced
1:0b0e5f3b1e83 2:5311817fb629
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 = array();
32 private $hasBeenStarted; 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)
37 * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) 37 * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag)
52 /** 52 /**
53 * {@inheritdoc} 53 * {@inheritdoc}
54 */ 54 */
55 public function start() 55 public function start()
56 { 56 {
57 ++$this->usageIndex;
58
57 return $this->storage->start(); 59 return $this->storage->start();
58 } 60 }
59 61
60 /** 62 /**
61 * {@inheritdoc} 63 * {@inheritdoc}
140 { 142 {
141 return count($this->getAttributeBag()->all()); 143 return count($this->getAttributeBag()->all());
142 } 144 }
143 145
144 /** 146 /**
147 * @return int
148 *
149 * @internal
150 */
151 public function getUsageIndex()
152 {
153 return $this->usageIndex;
154 }
155
156 /**
145 * @return bool 157 * @return bool
146 * 158 *
147 * @internal 159 * @internal
148 */ 160 */
149 public function hasBeenStarted()
150 {
151 return $this->hasBeenStarted;
152 }
153
154 /**
155 * @return bool
156 *
157 * @internal
158 */
159 public function isEmpty() 161 public function isEmpty()
160 { 162 {
163 ++$this->usageIndex;
161 foreach ($this->data as &$data) { 164 foreach ($this->data as &$data) {
162 if (!empty($data)) { 165 if (!empty($data)) {
163 return false; 166 return false;
164 } 167 }
165 } 168 }
180 /** 183 /**
181 * {@inheritdoc} 184 * {@inheritdoc}
182 */ 185 */
183 public function migrate($destroy = false, $lifetime = null) 186 public function migrate($destroy = false, $lifetime = null)
184 { 187 {
188 ++$this->usageIndex;
189
185 return $this->storage->regenerate($destroy, $lifetime); 190 return $this->storage->regenerate($destroy, $lifetime);
186 } 191 }
187 192
188 /** 193 /**
189 * {@inheritdoc} 194 * {@inheritdoc}
190 */ 195 */
191 public function save() 196 public function save()
192 { 197 {
198 ++$this->usageIndex;
199
193 $this->storage->save(); 200 $this->storage->save();
194 } 201 }
195 202
196 /** 203 /**
197 * {@inheritdoc} 204 * {@inheritdoc}
228 /** 235 /**
229 * {@inheritdoc} 236 * {@inheritdoc}
230 */ 237 */
231 public function getMetadataBag() 238 public function getMetadataBag()
232 { 239 {
240 ++$this->usageIndex;
241
233 return $this->storage->getMetadataBag(); 242 return $this->storage->getMetadataBag();
234 } 243 }
235 244
236 /** 245 /**
237 * {@inheritdoc} 246 * {@inheritdoc}
238 */ 247 */
239 public function registerBag(SessionBagInterface $bag) 248 public function registerBag(SessionBagInterface $bag)
240 { 249 {
241 $this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->hasBeenStarted)); 250 $this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->usageIndex));
242 } 251 }
243 252
244 /** 253 /**
245 * {@inheritdoc} 254 * {@inheritdoc}
246 */ 255 */