major session refactoring.

This commit is contained in:
Taylor Otwell
2011-10-31 22:15:47 -05:00
parent 36ff7b81aa
commit 997a90bcf5
18 changed files with 484 additions and 503 deletions

View File

@@ -4,11 +4,6 @@ define('BLADE_EXT', '.blade.php');
define('CRLF', chr(13).chr(10));
define('EXT', '.php');
/**
* Define a function that registers an array of constants if they haven't
* haven't already been registered. This allows the constants to
* be changed from their default values when unit testing.
*/
function constants($constants)
{
foreach ($constants as $key => $value)
@@ -17,11 +12,6 @@ function constants($constants)
}
}
/**
* Register the core framework paths. All other paths are built on
* top of these core paths. All of these paths are changable by
* the developer in the front controller.
*/
$constants = array(
'APP_PATH' => realpath($application).'/',
'BASE_PATH' => realpath("$laravel/..").'/',
@@ -34,19 +24,13 @@ constants($constants);
unset($application, $public, $storage, $laravel);
/**
* Register all of the other framework paths. All of these paths
* are built on top of the core paths above. We still allow the
* developer to override these for easy unit testing.
*/
$constants = array(
'CACHE_PATH' => STORAGE_PATH.'cache/',
'CLASS_PATH' => APP_PATH.'classes/',
'CONFIG_PATH' => APP_PATH.'config/',
'CONTROLLER_PATH' => APP_PATH.'controllers/',
'DATABASE_PATH' => STORAGE_PATH.'database/',
'LANG_PATH' => APP_PATH.'language/',
'LIBRARY_PATH' => APP_PATH.'libraries/',
'MODEL_PATH' => APP_PATH.'models/',
'ROUTE_PATH' => APP_PATH.'routes/',
'SESSION_PATH' => STORAGE_PATH.'sessions/',
'SYS_CONFIG_PATH' => SYS_PATH.'config/',
@@ -57,11 +41,6 @@ $constants = array(
constants($constants);
/**
* Set the Laravel environment configuration path constant.
* The environment is controlled by setting an environment
* variable on the server running Laravel.
*/
$environment = (isset($_SERVER['LARAVEL_ENV'])) ? CONFIG_PATH.$_SERVER['LARAVEL_ENV'].'/' : '';
constants(array('ENV_CONFIG_PATH' => $environment));

View File

@@ -2,69 +2,20 @@
require 'constants.php';
/**
* Load the classes that can't be resolved through the auto-loader.
* These are typically classes that are used by the auto-loader or
* configuration classes, and therefore cannot be auto-loaded.
*/
require SYS_PATH.'arr'.EXT;
require SYS_PATH.'config'.EXT;
require SYS_PATH.'facades'.EXT;
require SYS_PATH.'container'.EXT;
require SYS_PATH.'autoloader'.EXT;
/**
* Load some core configuration files by default so we don't have to
* let them fall through the Config parser. This will allow us to
* load these files faster for each request.
*/
Config::load('application');
Config::load('container');
Config::load('session');
/**
* Bootstrap the application inversion of control (IoC) container.
* The container provides the convenient resolution of objects and
* their dependencies, allowing for flexibility and testability
* within the framework and application.
*/
require SYS_PATH.'container'.EXT;
IoC::bootstrap();
$container = new Container(Config::$items['container']);
spl_autoload_register(array(IoC::container()->core('autoloader'), 'load'));
IoC::$container = $container;
unset($container);
/**
* Register the application auto-loader. The auto-loader closure
* is responsible for the lazy-loading of all of the Laravel core
* classes, as well as the developer created libraries and models.
*/
$aliases = Config::$items['application']['aliases'];
spl_autoload_register(function($class) use ($aliases)
{
if (array_key_exists($class, $aliases))
{
return class_alias($aliases[$class], $class);
}
$file = strtolower(str_replace('\\', '/', $class));
foreach (array(BASE_PATH, MODEL_PATH, LIBRARY_PATH) as $path)
{
if (file_exists($path = $path.$file.EXT))
{
require_once $path;
return;
}
}
});
unset($aliases);
/**
* Define a few convenient global functions.
*/
function e($value)
{
return HTML::entities($value);