[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
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; 13 14 use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; 15 use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface; 16 use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; 17 use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; 18 use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; 19 use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface; 20 21 /** 22 * @author Fabien Potencier <fabien@symfony.com> 23 * @author Drak <drak@zikula.org> 24 */ 25 class Session implements SessionInterface, \IteratorAggregate, \Countable 26 { 27 protected $storage; 28 29 private $flashName; 30 private $attributeName; 31 32 /** 33 * @param SessionStorageInterface $storage A SessionStorageInterface instance 34 * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) 35 * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) 36 */ 37 public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null) 38 { 39 $this->storage = $storage ?: new NativeSessionStorage(); 40 41 $attributes = $attributes ?: new AttributeBag(); 42 $this->attributeName = $attributes->getName(); 43 $this->registerBag($attributes); 44 45 $flashes = $flashes ?: new FlashBag(); 46 $this->flashName = $flashes->getName(); 47 $this->registerBag($flashes); 48 } 49 50 /** 51 * {@inheritdoc} 52 */ 53 public function start() 54 { 55 return $this->storage->start(); 56 } 57 58 /** 59 * {@inheritdoc} 60 */ 61 public function has($name) 62 { 63 return $this->storage->getBag($this->attributeName)->has($name); 64 } 65 66 /** 67 * {@inheritdoc} 68 */ 69 public function get($name, $default = null) 70 { 71 return $this->storage->getBag($this->attributeName)->get($name, $default); 72 } 73 74 /** 75 * {@inheritdoc} 76 */ 77 public function set($name, $value) 78 { 79 $this->storage->getBag($this->attributeName)->set($name, $value); 80 } 81 82 /** 83 * {@inheritdoc} 84 */ 85 public function all() 86 { 87 return $this->storage->getBag($this->attributeName)->all(); 88 } 89 90 /** 91 * {@inheritdoc} 92 */ 93 public function replace(array $attributes) 94 { 95 $this->storage->getBag($this->attributeName)->replace($attributes); 96 } 97 98 /** 99 * {@inheritdoc} 100 */ 101 public function remove($name) 102 { 103 return $this->storage->getBag($this->attributeName)->remove($name); 104 } 105 106 /** 107 * {@inheritdoc} 108 */ 109 public function clear() 110 { 111 $this->storage->getBag($this->attributeName)->clear(); 112 } 113 114 /** 115 * {@inheritdoc} 116 */ 117 public function isStarted() 118 { 119 return $this->storage->isStarted(); 120 } 121 122 /** 123 * Returns an iterator for attributes. 124 * 125 * @return \ArrayIterator An \ArrayIterator instance 126 */ 127 public function getIterator() 128 { 129 return new \ArrayIterator($this->storage->getBag($this->attributeName)->all()); 130 } 131 132 /** 133 * Returns the number of attributes. 134 * 135 * @return int The number of attributes 136 */ 137 public function count() 138 { 139 return \count($this->storage->getBag($this->attributeName)->all()); 140 } 141 142 /** 143 * {@inheritdoc} 144 */ 145 public function invalidate($lifetime = null) 146 { 147 $this->storage->clear(); 148 149 return $this->migrate(true, $lifetime); 150 } 151 152 /** 153 * {@inheritdoc} 154 */ 155 public function migrate($destroy = false, $lifetime = null) 156 { 157 return $this->storage->regenerate($destroy, $lifetime); 158 } 159 160 /** 161 * {@inheritdoc} 162 */ 163 public function save() 164 { 165 $this->storage->save(); 166 } 167 168 /** 169 * {@inheritdoc} 170 */ 171 public function getId() 172 { 173 return $this->storage->getId(); 174 } 175 176 /** 177 * {@inheritdoc} 178 */ 179 public function setId($id) 180 { 181 if ($this->storage->getId() !== $id) { 182 $this->storage->setId($id); 183 } 184 } 185 186 /** 187 * {@inheritdoc} 188 */ 189 public function getName() 190 { 191 return $this->storage->getName(); 192 } 193 194 /** 195 * {@inheritdoc} 196 */ 197 public function setName($name) 198 { 199 $this->storage->setName($name); 200 } 201 202 /** 203 * {@inheritdoc} 204 */ 205 public function getMetadataBag() 206 { 207 return $this->storage->getMetadataBag(); 208 } 209 210 /** 211 * {@inheritdoc} 212 */ 213 public function registerBag(SessionBagInterface $bag) 214 { 215 $this->storage->registerBag($bag); 216 } 217 218 /** 219 * {@inheritdoc} 220 */ 221 public function getBag($name) 222 { 223 return $this->storage->getBag($name); 224 } 225 226 /** 227 * Gets the flashbag interface. 228 * 229 * @return FlashBagInterface 230 */ 231 public function getFlashBag() 232 { 233 return $this->getBag($this->flashName); 234 } 235 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |