more refactoring and changes.

This commit is contained in:
Taylor Otwell
2011-09-08 17:49:16 -05:00
parent 03654fc5a1
commit abc1fad6c1
34 changed files with 883 additions and 482 deletions

View File

@@ -5,6 +5,33 @@
// --------------------------------------------------------------
require 'bootstrap.php';
// --------------------------------------------------------------
// Get an instance of the configuration manager.
// --------------------------------------------------------------
$config = $container->resolve('laravel.config');
set_exception_handler(function($e) use ($config)
{
call_user_func($config->get('error.handler'), $e);
});
set_error_handler(function($number, $error, $file, $line) use ($config)
{
$exception = new \ErrorException($error, $number, 0, $file, $line);
call_user_func($config->get('error.handler'), $exception);
});
register_shutdown_function(function() use ($config)
{
if ( ! is_null($error = error_get_last()))
{
$exception = new \ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']);
call_user_func($config->get('error.handler'), $exception);
}
});
// --------------------------------------------------------------
// Set the error reporting and display levels.
// --------------------------------------------------------------
@@ -12,58 +39,21 @@ error_reporting(-1);
ini_set('display_errors', 'Off');
// --------------------------------------------------------------
// Register the error / exception handlers.
// --------------------------------------------------------------
set_exception_handler(function($e) use ($container)
{
call_user_func($container->config->get('error.handler'), $e);
});
set_error_handler(function($number, $error, $file, $line) use ($container)
{
$exception = new \ErrorException($error, $number, 0, $file, $line);
call_user_func($container->config->get('error.handler'), $exception);
});
register_shutdown_function(function() use ($container)
{
if ( ! is_null($error = error_get_last()))
{
$exception = new \ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']);
call_user_func($container->config->get('error.handler'), $exception);
}
});
// --------------------------------------------------------------
// Set the default timezone.
// --------------------------------------------------------------
date_default_timezone_set($container->config->get('application.timezone'));
date_default_timezone_set($config->get('application.timezone'));
// --------------------------------------------------------------
// Load the session and session manager.
// --------------------------------------------------------------
if ($container->config->get('session.driver') !== '')
if ($config->get('session.driver') !== '')
{
$cookie = $container->input->cookies->get('laravel_session');
$cookie = $container->resolve('laravel.input')->cookies->get('laravel_session');
$container->session->start($cookie, $container->config->get('session.lifetime'));
$container->resolve('laravel.session')->start($cookie, $config->get('session'));
}
// --------------------------------------------------------------
// Load the packages that are in the auto-loaded packages array.
// --------------------------------------------------------------
$packages = $container->config->get('application.packages');
if (count($packages) > 0)
{
$container->package->load($packages);
}
unset($packages);
// --------------------------------------------------------------
// Route the request and get the response from the route.
// --------------------------------------------------------------
@@ -71,13 +61,11 @@ $route = $container->resolve('laravel.routing.router')->route();
if ( ! is_null($route))
{
$route->filters = require APP_PATH.'filters'.EXT;
$response = $container->resolve('laravel.routing.caller')->call($route);
}
else
{
$response = $container->response->error('404');
$response = $container->resolve('laravel.response')->error('404');
}
// --------------------------------------------------------------
@@ -88,9 +76,9 @@ $response->content = $response->render();
// --------------------------------------------------------------
// Close the session.
// --------------------------------------------------------------
if ($container->config->get('session.driver') !== '')
if ($config->get('session.driver') !== '')
{
$container->session->close($container->input, $container->config->get('session'));
$container->resolve('laravel.session')->close($container->resolve('laravel.input'));
}
// --------------------------------------------------------------