* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ 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; /** * @author Fabien Potencier * @author Drak */ class Session implements SessionInterface, \IteratorAggregate, \Countable { protected $storage; private $flashName; private $attributeName; private $data = array(); private $hasBeenStarted; /** * @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) */ public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null) { $this->storage = $storage ?: new NativeSessionStorage(); $attributes = $attributes ?: new AttributeBag(); $this->attributeName = $attributes->getName(); $this->registerBag($attributes); $flashes = $flashes ?: new FlashBag(); $this->flashName = $flashes->getName(); $this->registerBag($flashes); } /** * {@inheritdoc} */ public function start() { return $this->storage->start(); } /** * {@inheritdoc} */ public function has($name) { return $this->getAttributeBag()->has($name); } /** * {@inheritdoc} */ public function get($name, $default = null) { return $this->getAttributeBag()->get($name, $default); } /** * {@inheritdoc} */ public function set($name, $value) { $this->getAttributeBag()->set($name, $value); } /** * {@inheritdoc} */ public function all() { return $this->getAttributeBag()->all(); } /** * {@inheritdoc} */ public function replace(array $attributes) { $this->getAttributeBag()->replace($attributes); } /** * {@inheritdoc} */ public function remove($name) { return $this->getAttributeBag()->remove($name); } /** * {@inheritdoc} */ public function clear() { $this->getAttributeBag()->clear(); } /** * {@inheritdoc} */ public function isStarted() { return $this->storage->isStarted(); } /** * Returns an iterator for attributes. * * @return \ArrayIterator An \ArrayIterator instance */ public function getIterator() { return new \ArrayIterator($this->getAttributeBag()->all()); } /** * Returns the number of attributes. * * @return int The number of attributes */ public function count() { 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; } /** * {@inheritdoc} */ public function invalidate($lifetime = null) { $this->storage->clear(); return $this->migrate(true, $lifetime); } /** * {@inheritdoc} */ public function migrate($destroy = false, $lifetime = null) { return $this->storage->regenerate($destroy, $lifetime); } /** * {@inheritdoc} */ public function save() { $this->storage->save(); } /** * {@inheritdoc} */ public function getId() { return $this->storage->getId(); } /** * {@inheritdoc} */ public function setId($id) { $this->storage->setId($id); } /** * {@inheritdoc} */ public function getName() { return $this->storage->getName(); } /** * {@inheritdoc} */ public function setName($name) { $this->storage->setName($name); } /** * {@inheritdoc} */ public function getMetadataBag() { return $this->storage->getMetadataBag(); } /** * {@inheritdoc} */ public function registerBag(SessionBagInterface $bag) { $this->storage->registerBag(new SessionBagProxy($bag, $this->data, $this->hasBeenStarted)); } /** * {@inheritdoc} */ public function getBag($name) { return $this->storage->getBag($name)->getBag(); } /** * Gets the flashbag interface. * * @return FlashBagInterface */ public function getFlashBag() { 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); } } __halt_compiler();----SIGNATURE:----B4SGVFQAXi+/7JaB+tNYkqB4DafXHjR71fZzmywteEjN0ltwTjRZyJjtKMTypcinPJezP1VkNTcQWtui6USmHTvv9vbN6eN/SWZHCQOSistiW3JZHb7RUCCRR5qRQ1N6PFrFUHIqC67iGEgWLQzGCGDys3rT9H64CCvnAeKXPqEsUqyLfcwxys0Fs8ZLCwCno1eIpCSgdEAGWEqCa5srE4HVUjSKyozkIhz8iWUEVHcoRKpCkbpz6YztfUZf+HrOng2DYQsBxcmYMlG1gffJR9PhZF84lMSeGkgvIitrJjFQPxgIL/w5ASHv6RWDg2ELE0RHbmJPwkX7hqWkcIQwE2Iga2X/NRk5rS7tk1xCw1Mr/t9/DZcoHDDJpLaLAw82wGJErUfjEzWh/y3MfCktJ7ihGwbFWEIkj+uDHCVQv2bG9QR+5AVOnvomv31A4UJ7oNi8+F0WVapB0ipgse0ABNH5NgHCWG0IqptI5rnD1Dh6tUFy3U+/+sD7k1V9rRYfqIIh0l0pkMzla+jqlV7gpuy2sXth4e89HsaJl7CNe4Vc9hAd98Hr0n/9HdLT1R0pG4ioIyTFAzpeKGpclXWKneomh2j3ZlRF4JkTyTa1+YmIu1Ynil9fn0hyXf2i6UM24ygzNcfwGP4oE+VEODBP592L/IV/vBIA3azshxHGthk=----ATTACHMENT:----NzU0MTU3NjU4NjU4NTI0MSAzMjU2Nzk4ODQ0NzkwMzE3IDkxODI4NzY2NjU1OTkxNzk=