Commit 77fe8b67 authored by Taylor Otwell's avatar Taylor Otwell

moved input over to httpfoundation.

parent bcd3bd85
......@@ -161,19 +161,4 @@ $bundles = require path('app').'bundles'.EXT;
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
......@@ -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 @@ class Input {
*/
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.
*
* <code>
* // 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');
* </code>
*
* @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);
}
/**
......
......@@ -57,77 +57,18 @@ error_reporting(-1);
/*
|--------------------------------------------------------------------------
| 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);
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]);
use Symfony\Component\HttpFoundation\Request as FoundationRequest;
Input::$input = $input;
Request::$foundation = FoundationRequest::createFromGlobals();
/*
|--------------------------------------------------------------------------
......
......@@ -112,7 +112,7 @@ class Paginator {
*/
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment