Files
spa-api/laravel/session/manager.php

45 lines
942 B
PHP
Raw Normal View History

<?php namespace Laravel\Session;
2011-06-08 23:45:08 -05:00
2011-08-26 21:42:04 -05:00
use Laravel\Container;
class Manager {
2011-06-08 23:45:08 -05:00
/**
* The container instance.
*
* @var Container
*/
private $container;
/**
* Create a new session manager instance.
*
* @param Container $container
* @return void
*/
public function __construct(Container $container)
{
$this->container = $container;
}
2011-06-08 23:45:08 -05:00
/**
* Get the session driver.
2011-06-08 23:45:08 -05:00
*
2011-08-19 20:12:39 -05:00
* The session driver returned will be the driver specified in the session configuration
* file. Only one session driver may be active for a given request, so the driver will
* be managed as a singleton.
*
2011-08-26 21:42:04 -05:00
* @param string $driver
2011-06-08 23:45:08 -05:00
* @return Session\Driver
*/
2011-08-31 00:07:45 -05:00
public function driver($driver)
2011-06-08 23:45:08 -05:00
{
2011-08-26 21:42:04 -05:00
if (in_array($driver, array('cookie', 'file', 'database', 'apc', 'memcached')))
2011-06-08 23:45:08 -05:00
{
return $this->container->resolve('laravel.session.'.$driver);
2011-06-08 23:45:08 -05:00
}
2011-08-08 09:58:44 -05:00
2011-08-26 21:42:04 -05:00
throw new \Exception("Session driver [$driver] is not supported.");
2011-08-08 09:58:44 -05:00
}
2011-06-08 23:45:08 -05:00
}