Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/http-foundation/Session/Session.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | c2387f117808 |
line wrap: on
line diff
--- a/vendor/symfony/http-foundation/Session/Session.php Mon Apr 23 09:33:26 2018 +0100 +++ b/vendor/symfony/http-foundation/Session/Session.php Mon Apr 23 09:46:53 2018 +0100 @@ -19,33 +19,19 @@ use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage; /** - * Session. - * * @author Fabien Potencier <fabien@symfony.com> * @author Drak <drak@zikula.org> */ class Session implements SessionInterface, \IteratorAggregate, \Countable { - /** - * Storage driver. - * - * @var SessionStorageInterface - */ protected $storage; - /** - * @var string - */ private $flashName; + private $attributeName; + private $data = array(); + private $hasBeenStarted; /** - * @var string - */ - private $attributeName; - - /** - * 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 @@ */ public function has($name) { - return $this->storage->getBag($this->attributeName)->has($name); + return $this->getAttributeBag()->has($name); } /** @@ -84,7 +70,7 @@ */ 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 @@ */ public function set($name, $value) { - $this->storage->getBag($this->attributeName)->set($name, $value); + $this->getAttributeBag()->set($name, $value); } /** @@ -100,7 +86,7 @@ */ public function all() { - return $this->storage->getBag($this->attributeName)->all(); + return $this->getAttributeBag()->all(); } /** @@ -108,7 +94,7 @@ */ public function replace(array $attributes) { - $this->storage->getBag($this->attributeName)->replace($attributes); + $this->getAttributeBag()->replace($attributes); } /** @@ -116,7 +102,7 @@ */ public function remove($name) { - return $this->storage->getBag($this->attributeName)->remove($name); + return $this->getAttributeBag()->remove($name); } /** @@ -124,7 +110,7 @@ */ public function clear() { - $this->storage->getBag($this->attributeName)->clear(); + $this->getAttributeBag()->clear(); } /** @@ -142,7 +128,7 @@ */ public function getIterator() { - return new \ArrayIterator($this->storage->getBag($this->attributeName)->all()); + return new \ArrayIterator($this->getAttributeBag()->all()); } /** @@ -152,7 +138,33 @@ */ public function count() { - return count($this->storage->getBag($this->attributeName)->all()); + return count($this->getAttributeBag()->all()); + } + + /** + * @return bool + * + * @internal + */ + public function hasBeenStarted() + { + return $this->hasBeenStarted; + } + + /** + * @return bool + * + * @internal + */ + public function isEmpty() + { + foreach ($this->data as &$data) { + if (!empty($data)) { + return false; + } + } + + return true; } /** @@ -226,7 +238,7 @@ */ public function registerBag(SessionBagInterface $bag) { - $this->storage->registerBag($bag); + $this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->hasBeenStarted)); } /** @@ -234,7 +246,7 @@ */ public function getBag($name) { - return $this->storage->getBag($name); + return $this->storage->getBag($name)->getBag(); } /** @@ -246,4 +258,16 @@ { 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); + } }