8000 [2.1] Support PHP 5.4 \SessionHandler · Pull Request #3493 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.1] Support PHP 5.4 \SessionHandler #3493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from Mar 15, 2012
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[HttpFoundation] Remove hard coded assumptions and replace with API c…
…alls.
  • Loading branch information
Drak committed Mar 15, 2012
commit eb9bf056372f718bee3595801ee2b60955fba135
36 changes: 26 additions & 10 deletions src/Symfony/Component/HttpFoundation/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ class Session implements SessionInterface
*/
protected $storage;

/**
* @var string
*/
private $flashName;

/**
* @var string
*/
private $attributeName;

/**
* Constructor.
*
Expand All @@ -46,8 +56,14 @@ class Session implements SessionInterface
public function __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null)
{
$this->storage = $storage ?: new NativeSessionStorage();
$this->registerBag($attributes ?: new AttributeBag());
$this->registerBag($flashes ?: new FlashBag());

$attributeBag = $attributes ?: new AttributeBag();
$this->attributeName = $attributeBag->getName();
$this->registerBag($attributeBag);

$flashBag = $flashes ?: new FlashBag();
$this->flashName = $flashBag->getName();
$this->registerBag($flashBag);
}

/**
Expand All @@ -63,55 +79,55 @@ public function start()
*/
public function has($name)
{
return $this->storage->getBag('attributes')->has($name);
return $this->storage->getBag($this->attributeName)->has($name);
}

/**
* {@inheritdoc}
*/
public function get($name, $default = null)
{
return $this->storage->getBag('attributes')->get($name, $default);
return $this->storage->getBag($this->attributeName)->get($name, $default);
}

/**
* {@inheritdoc}
*/
public function set($name, $value)
{
$this->storage->getBag('attributes')->set($name, $value);
$this->storage->getBag($this->attributeName)->set($name, $value);
}

/**
* {@inheritdoc}
*/
public function all()
{
return $this->storage->getBag('attributes')->all();
return $this->storage->getBag($this->attributeName)->all();
}

/**
* {@inheritdoc}
*/
public function replace(array $attributes)
{
$this->storage->getBag('attributes')->replace($attributes);
$this->storage->getBag($this->attributeName)->replace($attributes);
}

/**
* {@inheritdoc}
*/
public function remove($name)
{
return $this->storage->getBag('attributes')->remove($name);
return $this->storage->getBag($this->attributeName)->remove($name);
}

/**
* {@inheritdoc}
*/
public function clear()
{
$this->storage->getBag('attributes')->clear();
$this->storage->getBag($this->attributeName)->clear();
}

/**
Expand Down Expand Up @@ -201,7 +217,7 @@ public function getBag($name)
*/
public function getFlashBag()
{
return $this->getBag('flashes');
return $this->getBag($this->flashName);
}

// the following methods are kept for compatibility with Symfony 2.0 (they will be removed for Symfony 2.3)
Expand Down
0