refactoring for better dependency injection on a few classes.
This commit is contained in:
@@ -37,52 +37,12 @@ if (Config::$items['session']['driver'] !== '')
|
||||
* Manually load some core classes that are used on every request
|
||||
* This allows to avoid using the loader for these classes.
|
||||
*/
|
||||
require SYS_PATH.'uri'.EXT;
|
||||
require SYS_PATH.'input'.EXT;
|
||||
require SYS_PATH.'request'.EXT;
|
||||
require SYS_PATH.'response'.EXT;
|
||||
require SYS_PATH.'routing/route'.EXT;
|
||||
require SYS_PATH.'routing/router'.EXT;
|
||||
require SYS_PATH.'routing/loader'.EXT;
|
||||
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.
|
||||
*/
|
||||
$input = array();
|
||||
|
||||
switch (Request::method())
|
||||
{
|
||||
case 'GET':
|
||||
$input = $_GET;
|
||||
break;
|
||||
|
||||
case 'POST':
|
||||
$input = $_POST;
|
||||
break;
|
||||
|
||||
case 'PUT':
|
||||
case 'DELETE':
|
||||
if (Request::spoofed())
|
||||
{
|
||||
$input = $_POST;
|
||||
}
|
||||
else
|
||||
{
|
||||
parse_str(file_get_contents('php://input'), $input);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The spoofed request method is removed from the input so it is
|
||||
* not unexpectedly included in Input::all() or Input::get().s
|
||||
*/
|
||||
unset($input[Request::spoofer]);
|
||||
|
||||
Input::$input = $input;
|
||||
|
||||
/**
|
||||
* Route the request to the proper route in the application. If a
|
||||
* route is found, the route will be called with the current request
|
||||
@@ -91,13 +51,13 @@ Input::$input = $input;
|
||||
*/
|
||||
Routing\Filter::register(require APP_PATH.'filters'.EXT);
|
||||
|
||||
list($uri, $method) = array(Request::uri()->get(), Request::method());
|
||||
$request = IoC::container()->core('request');
|
||||
|
||||
Request::$route = IoC::container()->core('routing.router')->route($method, $uri);
|
||||
$request->route = IoC::container()->core('routing.router')->route($request);
|
||||
|
||||
if ( ! is_null(Request::$route))
|
||||
if ( ! is_null($request->route))
|
||||
{
|
||||
$response = Request::$route->call();
|
||||
$response = $request->route->call();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user