diff --git a/laravel/core.php b/laravel/core.php index b78e47d8..2606b91f 100644 --- a/laravel/core.php +++ b/laravel/core.php @@ -161,19 +161,4 @@ foreach ($bundles as $bundle => $config) { Bundle::register($bundle, $config); -} - -/* -|-------------------------------------------------------------------------- -| Register The Laravel Bundles -|-------------------------------------------------------------------------- -| -| Finally we will register all of the bundles that have been defined for -| the application. None of them will be started, yet but will be setup -| so that they may be started by the develop at any time. -| -*/ - -use Symfony\Component\HttpFoundation\Request as FoundationRequest; - -Request::$foundation = FoundationRequest::createFromGlobals(); \ No newline at end of file +} \ No newline at end of file diff --git a/laravel/input.php b/laravel/input.php index e1239e72..f8785711 100644 --- a/laravel/input.php +++ b/laravel/input.php @@ -2,13 +2,6 @@ class Input { - /** - * The applicable input for the request. - * - * @var array - */ - public static $input; - /** * The key used to store old input in the session. * @@ -23,7 +16,11 @@ class Input { */ public static function all() { - return array_merge(static::get(), static::file()); + $input = array_merge(static::get(), static::query(), $_FILES); + + unset($input[Request::spoofer]); + + return $input; } /** @@ -58,7 +55,27 @@ public static function has($key) */ public static function get($key = null, $default = null) { - return array_get(static::$input, $key, $default); + return array_get(Request::foundation()->request->all(), $key, $default); + } + + /** + * Get an item from the query string. + * + * + * // Get the "email" item from the query string + * $email = Input::query('email'); + * + * // Return a default value if the specified item doesn't exist + * $email = Input::query('name', 'Taylor'); + * + * + * @param string $key + * @param mixed $default + * @return mixed + */ + public static function query($key = null, $default = null) + { + return array_get(Request::foundation()->query->all(), $key, $default); } /** diff --git a/laravel/laravel.php b/laravel/laravel.php index 4cd4ea00..132c683b 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -57,77 +57,18 @@ /* |-------------------------------------------------------------------------- -| Magic Quotes Strip Slashes +| Create The HttpFoundation Request |-------------------------------------------------------------------------- | -| Even though "Magic Quotes" are deprecated in PHP 5.3.x, they may still -| be enabled on the server. To account for this, we will strip slashes -| on all input arrays if magic quotes are enabled for the server. +| Laravel uses the HttpFoundation Symfony component to handle the request +| and response functionality for the framework. This allows us to not +| worry about that boilerplate code and focus on what matters. | */ -if (magic_quotes()) -{ - $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); +use Symfony\Component\HttpFoundation\Request as FoundationRequest; - foreach ($magics as &$magic) - { - $magic = array_strip_slashes($magic); - } -} - -/* -|-------------------------------------------------------------------------- -| Sniff The Input For The Request -|-------------------------------------------------------------------------- -| -| Next we'll gather the input to the application based on the global input -| variables for the current request. The input will be gathered based on -| the current request method and will be set on the Input manager class -| as a simple static $input property which can be easily accessed. -| -*/ - -$input = array(); - -switch (Request::method()) -{ - case 'GET': - $input = $_GET; - break; - - case 'POST': - $input = $_POST; - break; - - default: - if (Request::spoofed()) - { - $input = $_POST; - } - else - { - parse_str(file_get_contents('php://input'), $input); - - if (magic_quotes()) $input = array_strip_slashes($input); - } -} - -/* -|-------------------------------------------------------------------------- -| Remove The Spoofer Input -|-------------------------------------------------------------------------- -| -| The spoofed request method is removed from the input so it is not in -| the Input::all() or Input::get() results. Leaving it in the array -| could cause unexpected results since the developer won't be -| expecting it to be present. -| -*/ - -unset($input[Request::spoofer]); - -Input::$input = $input; +Request::$foundation = FoundationRequest::createFromGlobals(); /* |-------------------------------------------------------------------------- diff --git a/laravel/paginator.php b/laravel/paginator.php index ceffbe85..854b0e37 100644 --- a/laravel/paginator.php +++ b/laravel/paginator.php @@ -112,7 +112,7 @@ public static function make($results, $total, $per_page) */ public static function page($total, $per_page) { - $page = Input::get('page', 1); + $page = Input::query('page', 1); // The page will be validated and adjusted if it is less than one or greater // than the last page. For example, if the current page is not an integer or