You are here

public function NativeSessionStorage::getBag in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php \Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage::getBag()

Gets a SessionBagInterface by name.

Parameters

string $name:

Return value

SessionBagInterface

Throws

\InvalidArgumentException If the bag does not exist

Overrides SessionStorageInterface::getBag

File

vendor/symfony/http-foundation/Session/Storage/NativeSessionStorage.php, line 269

Class

NativeSessionStorage
This provides a base class for session attribute storage.

Namespace

Symfony\Component\HttpFoundation\Session\Storage

Code

public function getBag($name) {
  if (!isset($this->bags[$name])) {
    throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name));
  }
  if ($this->saveHandler
    ->isActive() && !$this->started) {
    $this
      ->loadSession();
  }
  elseif (!$this->started) {
    $this
      ->start();
  }
  return $this->bags[$name];
}