Chris@14: Chris@14: * Chris@14: * For the full copyright and license information, please view the LICENSE Chris@14: * file that was distributed with this source code. Chris@14: */ Chris@14: Chris@14: namespace Symfony\Component\HttpFoundation\Session; Chris@14: Chris@14: /** Chris@14: * @author Nicolas Grekas
Chris@14: * Chris@14: * @internal Chris@14: */ Chris@14: final class SessionBagProxy implements SessionBagInterface Chris@14: { Chris@14: private $bag; Chris@14: private $data; Chris@16: private $usageIndex; Chris@14: Chris@16: public function __construct(SessionBagInterface $bag, array &$data, &$usageIndex) Chris@14: { Chris@14: $this->bag = $bag; Chris@14: $this->data = &$data; Chris@16: $this->usageIndex = &$usageIndex; Chris@14: } Chris@14: Chris@14: /** Chris@14: * @return SessionBagInterface Chris@14: */ Chris@14: public function getBag() Chris@14: { Chris@16: ++$this->usageIndex; Chris@16: Chris@14: return $this->bag; Chris@14: } Chris@14: Chris@14: /** Chris@14: * @return bool Chris@14: */ Chris@14: public function isEmpty() Chris@14: { Chris@17: if (!isset($this->data[$this->bag->getStorageKey()])) { Chris@17: return true; Chris@17: } Chris@16: ++$this->usageIndex; Chris@16: Chris@14: return empty($this->data[$this->bag->getStorageKey()]); Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: public function getName() Chris@14: { Chris@14: return $this->bag->getName(); Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: public function initialize(array &$array) Chris@14: { Chris@16: ++$this->usageIndex; Chris@14: $this->data[$this->bag->getStorageKey()] = &$array; Chris@14: Chris@14: $this->bag->initialize($array); Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: public function getStorageKey() Chris@14: { Chris@14: return $this->bag->getStorageKey(); Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: public function clear() Chris@14: { Chris@14: return $this->bag->clear(); Chris@14: } Chris@14: }