moved input over to httpfoundation.
This commit is contained in:
parent
bcd3bd8591
commit
77fe8b6706
|
@ -162,18 +162,3 @@
|
|||
{
|
||||
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();
|
|
@ -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.
|
||||
*
|
||||
* <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 @@
|
|||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| 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();
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue