Allow the registration of third party cache and session drivers.
This commit is contained in:
@@ -9,6 +9,13 @@ class Session {
|
||||
*/
|
||||
public static $instance;
|
||||
|
||||
/**
|
||||
* The third-party driver registrar.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $registrar = array();
|
||||
|
||||
/**
|
||||
* The string name of the CSRF token stored in the session.
|
||||
*
|
||||
@@ -47,6 +54,11 @@ class Session {
|
||||
*/
|
||||
public static function factory($driver)
|
||||
{
|
||||
if (isset(static::$registrar[$driver]))
|
||||
{
|
||||
return static::$registrar[$driver]();
|
||||
}
|
||||
|
||||
switch ($driver)
|
||||
{
|
||||
case 'apc':
|
||||
@@ -105,6 +117,18 @@ class Session {
|
||||
return ! is_null(static::$instance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a third-party cache driver.
|
||||
*
|
||||
* @param string $driver
|
||||
* @param Closure $resolver
|
||||
* @return void
|
||||
*/
|
||||
public static function register($driver, Closure $resolver)
|
||||
{
|
||||
static::$registrar[$driver] = $resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic Method for calling the methods on the session singleton instance.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user