8000 [HttpFoundation][Session] Added a convenient method to get AttributeBagInterface by gmponos · Pull Request #21251 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation][Session] Added a convenient method to get AttributeBagInterface #21251

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
26 changes: 18 additions & 8 deletions src/Symfony/Component/HttpFoundation/Session/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,47 +76,47 @@ public function start()
*/
public function has($name)
{
return $this->storage->getBag($this->attributeName)->has($name);
return $this->getAttributeBag()->has($name);
}

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

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

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

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

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

/**
Expand All @@ -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());
}

/**
Expand All @@ -152,7 +152,7 @@ public function getIterator()
*/
public function count()
{
return count($this->storage->getBag($this->attributeName)->all());
return count($this->getAttributeBag()->all());
}

/**
Expand Down Expand Up @@ -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);
}
}
0