refactoring container for speed.

This commit is contained in:
Taylor Otwell
2011-10-05 18:32:48 -05:00
parent 4263203dda
commit 71b0ab8b8d
32 changed files with 1221 additions and 1486 deletions

View File

@@ -7,14 +7,7 @@ class Input {
*
* @var array
*/
protected $input;
/**
* The $_FILES array for the current request.
*
* @var array
*/
protected $files;
protected static $input;
/**
* The key used to store old input in the session.
@@ -24,16 +17,14 @@ class Input {
const old_input = 'laravel_old_input';
/**
* Create a new input manager instance.
* Set the input for the current request.
*
* @param array $input
* @param array $files
* @return void
*/
public function __construct($input, $files)
public static function set($input)
{
$this->input = $input;
$this->files = $files;
static::$input = $input;
}
/**
@@ -43,9 +34,9 @@ class Input {
*
* @return array
*/
public function all()
public static function all()
{
return array_merge($this->get(), $this->file());
return array_merge(static::get(), static::file());
}
/**
@@ -56,9 +47,9 @@ class Input {
* @param string $key
* @return bool
*/
public function has($key)
public static function has($key)
{
return ( ! is_null($this->get($key)) and trim((string) $this->get($key)) !== '');
return ( ! is_null(static::get($key)) and trim((string) static::get($key)) !== '');
}
/**
@@ -78,9 +69,9 @@ class Input {
* @param mixed $default
* @return mixed
*/
public function get($key = null, $default = null)
public static function get($key = null, $default = null)
{
return Arr::get($this->input, $key, $default);
return Arr::get(static::$input, $key, $default);
}
/**
@@ -89,9 +80,9 @@ class Input {
* @param string $key
* @return bool
*/
public function had($key)
public static function had($key)
{
return ( ! is_null($this->old($key)) and trim((string) $this->old($key)) !== '');
return ( ! is_null(static::old($key)) and trim((string) static::old($key)) !== '');
}
/**
@@ -109,7 +100,7 @@ class Input {
* @param mixed $default
* @return string
*/
public function old($key = null, $default = null)
public static function old($key = null, $default = null)
{
if (Config::get('session.driver') == '')
{
@@ -136,9 +127,9 @@ class Input {
* @param mixed $default
* @return array
*/
public function file($key = null, $default = null)
public static function file($key = null, $default = null)
{
return Arr::get($this->files, $key, $default);
return Arr::get($_FILES, $key, $default);
}
/**
@@ -155,9 +146,9 @@ class Input {
* @param string $path
* @return bool
*/
public function upload($key, $path)
public static function upload($key, $path)
{
return array_key_exists($key, $this->files) ? File::upload($key, $path, $this->files) : false;
return array_key_exists($key, $_FILES) ? File::upload($key, $path, $_FILES) : false;
}
}