cleaning up the autoloader and core bootstrapping.
This commit is contained in:
parent
56daba42c5
commit
8718b582df
|
@ -86,20 +86,6 @@ protected static function find($class)
|
|||
|
||||
return $path;
|
||||
}
|
||||
|
||||
// Since not all controllers will be resolved by the controller resolver,
|
||||
// we will do a quick check in the controller directory for the class.
|
||||
// For instance, since base controllers would not be resolved by the
|
||||
// controller class, we will need to resolve them here.
|
||||
if (strpos($class, '_Controller') !== false)
|
||||
{
|
||||
$controller = str_replace(array('_Controller', '_'), array('', '/'), $class);
|
||||
|
||||
if (file_exists($path = strtolower(CONTROLLER_PATH.$controller.EXT)))
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php namespace Laravel;
|
||||
|
||||
/**
|
||||
* Define all of the constants used by the framework. All of the core
|
||||
* paths will be defined, as well as all of the paths which derive
|
||||
* from these core paths.
|
||||
*/
|
||||
define('EXT', '.php');
|
||||
define('CRLF', chr(13).chr(10));
|
||||
define('BLADE_EXT', '.blade.php');
|
||||
|
@ -30,8 +25,10 @@
|
|||
|
||||
/**
|
||||
* Define the Laravel environment configuration path. This path is used
|
||||
* by the configuration class to load configuration options specific
|
||||
* for the server environment.
|
||||
* by the configuration class to load configuration options specific for
|
||||
* the server environment, allowing the developer to conveniently change
|
||||
* configuration options based on the application environment.
|
||||
*
|
||||
*/
|
||||
$environment = '';
|
||||
|
||||
|
|
|
@ -8,15 +8,12 @@
|
|||
require 'bootstrap/core.php';
|
||||
|
||||
/**
|
||||
* Register the framework error handling methods and set the
|
||||
* error_reporting levels. This file will register handlers
|
||||
* for exceptions, errors, and shutdown.
|
||||
* Register the framework error handling methods and set the error
|
||||
* reporting levels. This file will register handlers for exceptions,
|
||||
* errors, and the shutdown event.
|
||||
*/
|
||||
require SYS_PATH.'bootstrap/errors'.EXT;
|
||||
|
||||
/**
|
||||
* Set the application's default timezone.
|
||||
*/
|
||||
date_default_timezone_set(Config::$items['application']['timezone']);
|
||||
|
||||
/**
|
||||
|
@ -34,8 +31,9 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Manually load some core classes that are used on every request
|
||||
* This allows to avoid using the loader for these classes.
|
||||
* Manually load some core classes that are used on every request so
|
||||
* we can avoid using the loader for these classes. This saves us
|
||||
* some overhead on each request.
|
||||
*/
|
||||
require SYS_PATH.'input'.EXT;
|
||||
require SYS_PATH.'request'.EXT;
|
||||
|
@ -46,9 +44,9 @@
|
|||
require SYS_PATH.'routing/filter'.EXT;
|
||||
|
||||
/**
|
||||
* Gather the input to the application for the current request.
|
||||
* The input will be gathered based on the current request method
|
||||
* and will be set on the Input manager.
|
||||
* Gather the input to the application based on the current request.
|
||||
* The input will be gathered based on the current request method and
|
||||
* will be set on the Input manager.
|
||||
*/
|
||||
$input = array();
|
||||
|
||||
|
@ -75,8 +73,10 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* The spoofed request method is removed from the input so it is
|
||||
* not unexpectedly included in Input::all() or Input::get().
|
||||
* The spoofed request method is removed from the input so it is not
|
||||
* unexpectedly included in Input::all() or Input::get(). Leaving it
|
||||
* in the input array could cause unexpected results if the developer
|
||||
* fills an Eloquent model with the input.
|
||||
*/
|
||||
unset($input[Request::spoofer]);
|
||||
|
||||
|
@ -122,7 +122,4 @@
|
|||
IoC::container()->core('session')->save($driver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finally, we can send the response to the browser.
|
||||
*/
|
||||
$response->send();
|
|
@ -6,6 +6,24 @@
|
|||
use Laravel\Redirect;
|
||||
use Laravel\Response;
|
||||
|
||||
/**
|
||||
* Register a function on the autoload stack to lazy-load controller files.
|
||||
* We register this function here to keep the primary autoloader smaller
|
||||
* since this logic is not needed for every Laravel application.
|
||||
*/
|
||||
spl_autoload_register(function($controller)
|
||||
{
|
||||
if (strpos($controller, '_Controller') !== false)
|
||||
{
|
||||
$controller = str_replace(array('_Controller', '_'), array('', '/'), $controller);
|
||||
|
||||
if (file_exists($path = strtolower(CONTROLLER_PATH.$controller.EXT)))
|
||||
{
|
||||
return $path;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
abstract class Controller {
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue