X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fsymfony%2Fhttp-foundation%2FSession%2FSession.php;h=3349906875864333fa00f9441f777f47d957f64b;hb=4e1bfbf98b844da83b18aca92ef00f11a4735806;hp=cdd97375b905418465251231a0d0fd0eb9a8f18a;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/symfony/http-foundation/Session/Session.php b/vendor/symfony/http-foundation/Session/Session.php index cdd97375b..334990687 100644 --- a/vendor/symfony/http-foundation/Session/Session.php +++ b/vendor/symfony/http-foundation/Session/Session.php @@ -11,41 +11,27 @@ namespace Symfony\Component\HttpFoundation\Session; -use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface; use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; +use Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface; /** - * Session. - * * @author Fabien Potencier * @author Drak */ class Session implements SessionInterface, \IteratorAggregate, \Countable { - /** - * Storage driver. - * - * @var SessionStorageInterface - */ protected $storage; - /** - * @var string - */ private $flashName; - - /** - * @var string - */ private $attributeName; + private $data = array(); + private $usageIndex = 0; /** - * Constructor. - * * @param SessionStorageInterface $storage A SessionStorageInterface instance * @param AttributeBagInterface $attributes An AttributeBagInterface instance, (defaults null for default AttributeBag) * @param FlashBagInterface $flashes A FlashBagInterface instance (defaults null for default FlashBag) @@ -76,7 +62,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function has($name) { - return $this->storage->getBag($this->attributeName)->has($name); + return $this->getAttributeBag()->has($name); } /** @@ -84,7 +70,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function get($name, $default = null) { - return $this->storage->getBag($this->attributeName)->get($name, $default); + return $this->getAttributeBag()->get($name, $default); } /** @@ -92,7 +78,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function set($name, $value) { - $this->storage->getBag($this->attributeName)->set($name, $value); + $this->getAttributeBag()->set($name, $value); } /** @@ -100,7 +86,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function all() { - return $this->storage->getBag($this->attributeName)->all(); + return $this->getAttributeBag()->all(); } /** @@ -108,7 +94,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function replace(array $attributes) { - $this->storage->getBag($this->attributeName)->replace($attributes); + $this->getAttributeBag()->replace($attributes); } /** @@ -116,7 +102,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function remove($name) { - return $this->storage->getBag($this->attributeName)->remove($name); + return $this->getAttributeBag()->remove($name); } /** @@ -124,7 +110,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function clear() { - $this->storage->getBag($this->attributeName)->clear(); + $this->getAttributeBag()->clear(); } /** @@ -142,7 +128,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function getIterator() { - return new \ArrayIterator($this->storage->getBag($this->attributeName)->all()); + return new \ArrayIterator($this->getAttributeBag()->all()); } /** @@ -152,7 +138,36 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function count() { - return count($this->storage->getBag($this->attributeName)->all()); + return \count($this->getAttributeBag()->all()); + } + + /** + * @return int + * + * @internal + */ + public function getUsageIndex() + { + return $this->usageIndex; + } + + /** + * @return bool + * + * @internal + */ + public function isEmpty() + { + if ($this->isStarted()) { + ++$this->usageIndex; + } + foreach ($this->data as &$data) { + if (!empty($data)) { + return false; + } + } + + return true; } /** @@ -194,7 +209,9 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function setId($id) { - $this->storage->setId($id); + if ($this->storage->getId() !== $id) { + $this->storage->setId($id); + } } /** @@ -218,6 +235,8 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function getMetadataBag() { + ++$this->usageIndex; + return $this->storage->getMetadataBag(); } @@ -226,7 +245,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function registerBag(SessionBagInterface $bag) { - $this->storage->registerBag($bag); + $this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->usageIndex)); } /** @@ -234,7 +253,7 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable */ public function getBag($name) { - return $this->storage->getBag($name); + return $this->storage->getBag($name)->getBag(); } /** @@ -246,4 +265,16 @@ class Session implements SessionInterface, \IteratorAggregate, \Countable { return $this->getBag($this->flashName); } + + /** + * Gets the attributebag interface. + * + * Note that this method was added to help with IDE autocompletion. + * + * @return AttributeBagInterface + */ + private function getAttributeBag() + { + return $this->getBag($this->attributeName); + } }