From 6f533f791544bc2a07b5a959a95e0f46bd0b7b89 Mon Sep 17 00:00:00 2001 From: gmponos Date: Thu, 12 Jan 2017 22:02:22 +0200 Subject: [PATCH] Added a convenient method inside Session for getting internally the AttributeBagInterface and have also autompletion --- .../HttpFoundation/Session/Session.php | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Session.php b/src/Symfony/Component/HttpFoundation/Session/Session.php index cdd97375b9054..c48ac504d76ad 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Session.php +++ b/src/Symfony/Component/HttpFoundation/Session/Session.php @@ -76,7 +76,7 @@ public function start() */ public function has($name) { - return $this->storage->getBag($this->attributeName)->has($name); + return $this->getAttributeBag()->has($name); } /** @@ -84,7 +84,7 @@ public function has($name) */ public function get($name, $default = null) { - return $this->storage->getBag($this->attributeName)->get($name, $default); + return $this->getAttributeBag()->get($name, $default); } /** @@ -92,7 +92,7 @@ public function get($name, $default = null) */ public function set($name, $value) { - $this->storage->getBag($this->attributeName)->set($name, $value); + $this->getAttributeBag()->set($name, $value); } /** @@ -100,7 +100,7 @@ public function set($name, $value) */ public function all() { - return $this->storage->getBag($this->attributeName)->all(); + return $this->getAttributeBag()->all(); } /** @@ -108,7 +108,7 @@ public function all() */ public function replace(array $attributes) { - $this->storage->getBag($this->attributeName)->replace($attributes); + $this->getAttributeBag()->replace($attributes); } /** @@ -116,7 +116,7 @@ public function replace(array $attributes) */ public function remove($name) { - return $this->storage->getBag($this->attributeName)->remove($name); + return $this->getAttributeBag()->remove($name); } /** @@ -142,7 +142,7 @@ public function isStarted() */ public function getIterator() { - return new \ArrayIterator($this->storage->getBag($this->attributeName)->all()); + return new \ArrayIterator($this->getAttributeBag()->all()); } /** @@ -152,7 +152,7 @@ public function getIterator() */ public function count() { - return count($this->storage->getBag($this->attributeName)->all()); + return count($this->getAttributeBag()->all()); } /** @@ -246,4 +246,14 @@ public function getFlashBag() { return $this->getBag($this->flashName); } + + /** + * Gets the attributebag interface. + * + * @return AttributeBagInterface + */ + private function getAttributeBag() + { + return $this->storage->getBag($this->attributeName); + } }