Commit ba9a7263 by Taylor Otwell

Allow the registration of third party cache and session drivers.

parent c49c6036
......@@ -170,4 +170,4 @@ date_default_timezone_set(Config::get('application.timezone'));
if ( ! Request::cli() and Config::get('session.driver') !== '')
{
Session::load();
}
}
\ No newline at end of file
<?php namespace Laravel; defined('DS') or die('No direct script access.');
<?php namespace Laravel; use Closure;
class Cache {
......@@ -10,6 +10,13 @@ class Cache {
public static $drivers = array();
/**
* The third-party driver registrar.
*
* @var array
*/
public static $registrar = array();
/**
* Get a cache driver instance.
*
* If no driver name is specified, the default will be returned.
......@@ -45,6 +52,11 @@ class Cache {
*/
protected static function factory($driver)
{
if (isset(static::$registrar[$driver]))
{
return static::$registrar[$driver]();
}
switch ($driver)
{
case 'apc':
......@@ -71,6 +83,18 @@ class Cache {
}
/**
* 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 default cache driver.
*
* <code>
......
......@@ -10,6 +10,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.
*
* @var string
......@@ -47,6 +54,11 @@ class Session {
*/
public static function factory($driver)
{
if (isset(static::$registrar[$driver]))
{
return static::$registrar[$driver]();
}
switch ($driver)
{
case 'apc':
......@@ -106,6 +118,18 @@ class Session {
}
/**
* 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.
*
* <code>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment