various refactoring and tweaks.
This commit is contained in:
parent
df9130dafa
commit
af36cb3d5a
|
@ -45,8 +45,10 @@
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'servers' => array(
|
'memcached' => array(
|
||||||
|
|
||||||
array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
|
array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
);
|
);
|
|
@ -59,13 +59,19 @@
|
||||||
|
|
||||||
'auth' => function()
|
'auth' => function()
|
||||||
{
|
{
|
||||||
if ( ! Auth::check()) return Redirect::to_login();
|
if ( ! Auth::check())
|
||||||
|
{
|
||||||
|
return Redirect::to_login();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
'csrf' => function()
|
'csrf' => function()
|
||||||
{
|
{
|
||||||
if (Input::get('csrf_token') !== Form::raw_token()) return Response::error('500');
|
if (Input::get('csrf_token') !== Form::raw_token())
|
||||||
|
{
|
||||||
|
return Response::error('500');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
);
|
);
|
|
@ -49,7 +49,6 @@ function constants($constants)
|
||||||
'ROUTE_PATH' => APP_PATH.'routes/',
|
'ROUTE_PATH' => APP_PATH.'routes/',
|
||||||
'SESSION_PATH' => STORAGE_PATH.'sessions/',
|
'SESSION_PATH' => STORAGE_PATH.'sessions/',
|
||||||
'SYS_CONFIG_PATH' => SYS_PATH.'config/',
|
'SYS_CONFIG_PATH' => SYS_PATH.'config/',
|
||||||
'SYS_LANG_PATH' => SYS_PATH.'language/',
|
|
||||||
'SYS_VIEW_PATH' => SYS_PATH.'views/',
|
'SYS_VIEW_PATH' => SYS_PATH.'views/',
|
||||||
'VIEW_PATH' => APP_PATH.'views/',
|
'VIEW_PATH' => APP_PATH.'views/',
|
||||||
);
|
);
|
||||||
|
|
|
@ -6,8 +6,12 @@
|
||||||
* error handler to create a more readable message.
|
* error handler to create a more readable message.
|
||||||
*/
|
*/
|
||||||
$message = function($e)
|
$message = function($e)
|
||||||
{
|
{
|
||||||
$file = str_replace(array(APP_PATH, SYS_PATH), array('APP_PATH/', 'SYS_PATH/'), $e->getFile());
|
$search = array(APP_PATH, SYS_PATH);
|
||||||
|
|
||||||
|
$replace = array('APP_PATH/', 'SYS_PATH/');
|
||||||
|
|
||||||
|
$file = str_replace($search, $replace, $e->getFile());
|
||||||
|
|
||||||
return rtrim($e->getMessage(), '.').' in '.$file.' on line '.$e->getLine().'.';
|
return rtrim($e->getMessage(), '.').' in '.$file.' on line '.$e->getLine().'.';
|
||||||
};
|
};
|
||||||
|
@ -35,14 +39,23 @@
|
||||||
E_STRICT => 'Runtime Notice',
|
E_STRICT => 'Runtime Notice',
|
||||||
);
|
);
|
||||||
|
|
||||||
return (array_key_exists($e->getCode(), $levels)) ? $levels[$e->getCode()] : $e->getCode();
|
if (array_key_exists($e->getCode(), $levels))
|
||||||
|
{
|
||||||
|
$level = $levels[$e->getCode()];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$level = $e->getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $level;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the exception handler function. All of the error handlers
|
* Create the exception handler function. All of the error handlers
|
||||||
* registered with PHP call this closure to keep the code D.R.Y.
|
* registered by the framework call this closure to avoid duplicate
|
||||||
* Each of the formatting closures defined above will be passed
|
* code. Each of the formatting closures defined above will be
|
||||||
* into the handler for convenient use.
|
* passed into the handler for convenient use.
|
||||||
*/
|
*/
|
||||||
$handler = function($e) use ($message, $severity)
|
$handler = function($e) use ($message, $severity)
|
||||||
{
|
{
|
||||||
|
|
|
@ -61,7 +61,7 @@ abstract public function put($key, $value, $minutes);
|
||||||
* cache, store the default value in the cache and return it.
|
* cache, store the default value in the cache and return it.
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* // Get an item from the cache, or cache a value for 15 minutes if it doesn't exist
|
* // Get an item from the cache, or cache a value for 15 minutes
|
||||||
* $name = Cache::remember('name', 'Taylor', 15);
|
* $name = Cache::remember('name', 'Taylor', 15);
|
||||||
*
|
*
|
||||||
* // Use a closure for deferred execution
|
* // Use a closure for deferred execution
|
||||||
|
|
|
@ -12,8 +12,8 @@ class Manager {
|
||||||
/**
|
/**
|
||||||
* Get a cache driver instance.
|
* Get a cache driver instance.
|
||||||
*
|
*
|
||||||
* If no driver name is specified, the default cache driver will be
|
* If no driver name is specified, the default cache driver will
|
||||||
* returned as defined in the cache configuration file.
|
* be returned as defined in the cache configuration file.
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* // Get the default cache driver instance
|
* // Get the default cache driver instance
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
{
|
{
|
||||||
$memcache = new \Memcache;
|
$memcache = new \Memcache;
|
||||||
|
|
||||||
foreach (Config::get('cache.servers') as $server)
|
foreach (Config::get('cache.memcached') as $server)
|
||||||
{
|
{
|
||||||
$memcache->addServer($server['host'], $server['port'], true, $server['weight']);
|
$memcache->addServer($server['host'], $server['port'], true, $server['weight']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,36 @@ public function __construct(PDO $pdo, $config)
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin a fluent query against a table.
|
||||||
|
*
|
||||||
|
* @param string $table
|
||||||
|
* @return Query
|
||||||
|
*/
|
||||||
|
public function table($table)
|
||||||
|
{
|
||||||
|
return new Query($this, $this->grammar(), $table);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new query grammar for the connection.
|
||||||
|
*
|
||||||
|
* @return Grammars\Grammar
|
||||||
|
*/
|
||||||
|
protected function grammar()
|
||||||
|
{
|
||||||
|
if (isset($this->grammar)) return $this->grammar;
|
||||||
|
|
||||||
|
switch (isset($this->config['grammar']) ? $this->config['grammar'] : $this->driver())
|
||||||
|
{
|
||||||
|
case 'mysql':
|
||||||
|
return $this->grammar = new Grammars\MySQL;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return $this->grammar = new Grammars\Grammar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a SQL query against the connection and return a single column result.
|
* Execute a SQL query against the connection and return a single column result.
|
||||||
*
|
*
|
||||||
|
@ -109,18 +139,18 @@ public function first($sql, $bindings = array())
|
||||||
*/
|
*/
|
||||||
public function query($sql, $bindings = array())
|
public function query($sql, $bindings = array())
|
||||||
{
|
{
|
||||||
// First we need to remove all expressions from the bindings
|
// Remove expressions from the bindings since they injected into
|
||||||
// since they will be placed into the query as raw strings.
|
// the query as raw strings and are not bound parameters.
|
||||||
foreach ($bindings as $key => $value)
|
foreach ($bindings as $key => $value)
|
||||||
{
|
{
|
||||||
if ($value instanceof Expression) unset($bindings[$key]);
|
if ($value instanceof Expression) unset($bindings[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = $this->transform($sql, $bindings);
|
$sql = $this->transform(trim($sql), $bindings);
|
||||||
|
|
||||||
$this->queries[] = compact('sql', 'bindings');
|
$this->queries[] = compact('sql', 'bindings');
|
||||||
|
|
||||||
return $this->execute($this->pdo->prepare(trim($sql)), $bindings);
|
return $this->execute($this->pdo->prepare($sql), $bindings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -178,36 +208,6 @@ protected function execute(PDOStatement $statement, $bindings)
|
||||||
return $statement->rowCount();
|
return $statement->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Begin a fluent query against a table.
|
|
||||||
*
|
|
||||||
* @param string $table
|
|
||||||
* @return Query
|
|
||||||
*/
|
|
||||||
public function table($table)
|
|
||||||
{
|
|
||||||
return new Query($this, $this->grammar(), $table);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a new query grammar for the connection.
|
|
||||||
*
|
|
||||||
* @return Grammars\Grammar
|
|
||||||
*/
|
|
||||||
protected function grammar()
|
|
||||||
{
|
|
||||||
if (isset($this->grammar)) return $this->grammar;
|
|
||||||
|
|
||||||
switch (isset($this->config['grammar']) ? $this->config['grammar'] : $this->driver())
|
|
||||||
{
|
|
||||||
case 'mysql':
|
|
||||||
return $this->grammar = new Grammars\MySQL;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return $this->grammar = new Grammars\Grammar;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the driver name for the database connection.
|
* Get the driver name for the database connection.
|
||||||
*
|
*
|
||||||
|
|
|
@ -47,8 +47,6 @@ final public function select(Query $query)
|
||||||
{
|
{
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
// Iterate through each query component, calling the compiler for that
|
|
||||||
// component and passing the query instance into the compiler.
|
|
||||||
foreach ($this->components as $component)
|
foreach ($this->components as $component)
|
||||||
{
|
{
|
||||||
if ( ! is_null($query->$component))
|
if ( ! is_null($query->$component))
|
||||||
|
@ -111,9 +109,6 @@ protected function from(Query $query)
|
||||||
*/
|
*/
|
||||||
protected function joins(Query $query)
|
protected function joins(Query $query)
|
||||||
{
|
{
|
||||||
// Since creating a JOIN clause using string concatenation is a little
|
|
||||||
// cumbersome, we will create a format we can pass to "sprintf" to
|
|
||||||
// make things cleaner.
|
|
||||||
$format = '%s JOIN %s ON %s %s %s';
|
$format = '%s JOIN %s ON %s %s %s';
|
||||||
|
|
||||||
foreach ($query->joins as $join)
|
foreach ($query->joins as $join)
|
||||||
|
@ -281,9 +276,9 @@ public function insert(Query $query, $values)
|
||||||
// every insert to the table.
|
// every insert to the table.
|
||||||
$columns = $this->columnize(array_keys(reset($values)));
|
$columns = $this->columnize(array_keys(reset($values)));
|
||||||
|
|
||||||
// Build the list of parameter place-holders for the array of values bound
|
// Build the list of parameter place-holders of values bound to the query.
|
||||||
// to the query. Each insert statement should have the same number of bound
|
// Each insert should have the same number of bound paramters, so we can
|
||||||
// parameters, so we can just use the first array of values.
|
// just use the first array of values.
|
||||||
$parameters = $this->parameterize(reset($values));
|
$parameters = $this->parameterize(reset($values));
|
||||||
|
|
||||||
$parameters = implode(', ', array_fill(0, count($values), '('.$parameters.')'));
|
$parameters = implode(', ', array_fill(0, count($values), '('.$parameters.')'));
|
||||||
|
|
|
@ -270,7 +270,14 @@ private static function listing($type, $list, $attributes = array())
|
||||||
|
|
||||||
foreach ($list as $key => $value)
|
foreach ($list as $key => $value)
|
||||||
{
|
{
|
||||||
$html .= (is_array($value)) ? static::elements($type, $value) : '<li>'.static::entities($value).'</li>';
|
if (is_array($value))
|
||||||
|
{
|
||||||
|
$html .= static::elements($type, $value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$html .= '<li>'.static::entities($value).'</li>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return '<'.$type.static::attributes($attributes).'>'.$html.'</'.$type.'>';
|
return '<'.$type.static::attributes($attributes).'>'.$html.'</'.$type.'>';
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Lang {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $paths = array(SYS_LANG_PATH, LANG_PATH);
|
protected $paths = array(LANG_PATH);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Lang instance.
|
* Create a new Lang instance.
|
||||||
|
@ -164,9 +164,6 @@ protected function load($file)
|
||||||
|
|
||||||
$language = array();
|
$language = array();
|
||||||
|
|
||||||
// Language files cascade. Typically, the system language array is
|
|
||||||
// loaded first, followed by the application array. This allows the
|
|
||||||
// convenient overriding of the system language files.
|
|
||||||
foreach ($this->paths as $directory)
|
foreach ($this->paths as $directory)
|
||||||
{
|
{
|
||||||
if (file_exists($path = $directory.$this->language.'/'.$file.EXT))
|
if (file_exists($path = $directory.$this->language.'/'.$file.EXT))
|
||||||
|
|
|
@ -60,13 +60,11 @@ public static function call($destination, $parameters = array())
|
||||||
}
|
}
|
||||||
|
|
||||||
// The after filter and the framework expects all responses to
|
// The after filter and the framework expects all responses to
|
||||||
// be instances of the Response class. If the route did not
|
// be instances of the Response class. If the method did not
|
||||||
// return an instsance of Response, we will make on now.
|
// return an instsance of Response, we will make on now.
|
||||||
if ( ! $response instanceof Response) $response = new Response($response);
|
if ( ! $response instanceof Response) $response = new Response($response);
|
||||||
|
|
||||||
$filters = array_merge($controller->filters('after'), array('after'));
|
Filter::run($controller->filters('after'), array($response));
|
||||||
|
|
||||||
Filter::run($filters, array($response));
|
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,12 @@ public function call()
|
||||||
// Since "before" filters can halt the request cycle, we will return
|
// Since "before" filters can halt the request cycle, we will return
|
||||||
// any response from the before filters. Allowing filters to halt the
|
// any response from the before filters. Allowing filters to halt the
|
||||||
// request cycle makes tasks like authorization convenient.
|
// request cycle makes tasks like authorization convenient.
|
||||||
|
//
|
||||||
|
// The route is responsible for running the global filters, and any
|
||||||
|
// filters defined on the route itself. Since all incoming requests
|
||||||
|
// come through a route (either defined or ad-hoc), it makes sense
|
||||||
|
// to let the route handle the global filters. If the route uses
|
||||||
|
// a controller, the controller will only call its own filters.
|
||||||
$before = array_merge(array('before'), $this->filters('before'));
|
$before = array_merge(array('before'), $this->filters('before'));
|
||||||
|
|
||||||
if ( ! is_null($response = Filter::run($before, array(), true)))
|
if ( ! is_null($response = Filter::run($before, array(), true)))
|
||||||
|
@ -104,21 +110,22 @@ public function call()
|
||||||
{
|
{
|
||||||
if ($response instanceof Delegate)
|
if ($response instanceof Delegate)
|
||||||
{
|
{
|
||||||
return Controller::call($response->destination, $this->parameters);
|
$response = Controller::call($response->destination, $this->parameters);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// The after filter and the framework expects all responses to
|
||||||
|
// be instances of the Response class. If the route did not
|
||||||
|
// return an instsance of Response, we will make on now.
|
||||||
|
if ( ! $response instanceof Response)
|
||||||
{
|
{
|
||||||
// The after filter and the framework expects all responses to
|
$response = new Response($response);
|
||||||
// be instances of the Response class. If the route did not
|
|
||||||
// return an instsance of Response, we will make on now.
|
|
||||||
if ( ! $response instanceof Response) $response = new Response($response);
|
|
||||||
|
|
||||||
$filters = array_merge($this->filters('after'), array('after'));
|
|
||||||
|
|
||||||
Filter::run($filters, array($response));
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$filters = array_merge($this->filters('after'), array('after'));
|
||||||
|
|
||||||
|
Filter::run($filters, array($response));
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::error('404');
|
return Response::error('404');
|
||||||
|
|
|
@ -153,7 +153,10 @@ protected function match($destination, $keys, $callback)
|
||||||
foreach (explode(', ', $keys) as $key)
|
foreach (explode(', ', $keys) as $key)
|
||||||
{
|
{
|
||||||
// Append the provided formats to the route as an optional regular expression.
|
// Append the provided formats to the route as an optional regular expression.
|
||||||
if ( ! is_null($formats = $this->provides($callback))) $key .= '(\.('.implode('|', $formats).'))?';
|
if ( ! is_null($formats = $this->provides($callback)))
|
||||||
|
{
|
||||||
|
$key .= '(\.('.implode('|', $formats).'))?';
|
||||||
|
}
|
||||||
|
|
||||||
if (preg_match('#^'.$this->wildcards($key).'$#', $destination))
|
if (preg_match('#^'.$this->wildcards($key).'$#', $destination))
|
||||||
{
|
{
|
||||||
|
@ -216,7 +219,9 @@ protected function controller_key($segments)
|
||||||
{
|
{
|
||||||
foreach (array_reverse($segments, true) as $key => $value)
|
foreach (array_reverse($segments, true) as $key => $value)
|
||||||
{
|
{
|
||||||
if (file_exists($path = $this->controllers.implode('/', array_slice($segments, 0, $key + 1)).EXT))
|
$controller = implode('/', array_slice($segments, 0, $key + 1)).EXT;
|
||||||
|
|
||||||
|
if (file_exists($path = $this->controllers.$controller))
|
||||||
{
|
{
|
||||||
return $key + 1;
|
return $key + 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php namespace Laravel\Security;
|
<?php namespace Laravel\Security;
|
||||||
|
|
||||||
use Laravel\IoC;
|
|
||||||
use Laravel\Str;
|
use Laravel\Str;
|
||||||
use Laravel\Config;
|
use Laravel\Config;
|
||||||
use Laravel\Cookie;
|
use Laravel\Cookie;
|
||||||
|
@ -42,7 +41,7 @@ public static function check()
|
||||||
/**
|
/**
|
||||||
* Get the current user of the application.
|
* Get the current user of the application.
|
||||||
*
|
*
|
||||||
* This method will call the "user" closure in the authentication configuration file.
|
* This method will call the "user" closure in the auth configuration file.
|
||||||
* If the user is not authenticated, null will be returned by the methd.
|
* If the user is not authenticated, null will be returned by the methd.
|
||||||
*
|
*
|
||||||
* If no user exists in the session, the method will check for a "remember me"
|
* If no user exists in the session, the method will check for a "remember me"
|
||||||
|
@ -64,7 +63,9 @@ public static function user()
|
||||||
|
|
||||||
static::$user = call_user_func(Config::get('auth.user'), Session::get(Auth::user_key));
|
static::$user = call_user_func(Config::get('auth.user'), Session::get(Auth::user_key));
|
||||||
|
|
||||||
if (is_null(static::$user) and ! is_null($cookie = Cookie::get(Auth::remember_key)))
|
$cookie = Cookie::get(Auth::remember_key);
|
||||||
|
|
||||||
|
if (is_null(static::$user) and ! is_null($cookie))
|
||||||
{
|
{
|
||||||
static::$user = static::recall($cookie);
|
static::$user = static::recall($cookie);
|
||||||
}
|
}
|
||||||
|
@ -113,7 +114,9 @@ public static function attempt($username, $password = null, $remember = false)
|
||||||
{
|
{
|
||||||
$config = Config::get('auth');
|
$config = Config::get('auth');
|
||||||
|
|
||||||
if ( ! is_null($user = call_user_func($config['attempt'], $username, $password, $config)))
|
$user = call_user_func($config['attempt'], $username, $password, $config);
|
||||||
|
|
||||||
|
if ( ! is_null($user))
|
||||||
{
|
{
|
||||||
static::login($user, $config, $remember);
|
static::login($user, $config, $remember);
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,9 @@ public static function encrypt($value)
|
||||||
|
|
||||||
$iv = mcrypt_create_iv(static::iv_size(), $randomizer);
|
$iv = mcrypt_create_iv(static::iv_size(), $randomizer);
|
||||||
|
|
||||||
return base64_encode($iv.mcrypt_encrypt(static::$cipher, static::key(), $value, static::$mode, $iv));
|
$value = mcrypt_encrypt(static::$cipher, static::key(), $value, static::$mode, $iv);
|
||||||
|
|
||||||
|
return base64_encode($iv.$value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,20 +69,20 @@ public static function decrypt($value)
|
||||||
{
|
{
|
||||||
list($iv, $value) = static::parse(base64_decode($value, true));
|
list($iv, $value) = static::parse(base64_decode($value, true));
|
||||||
|
|
||||||
return rtrim(mcrypt_decrypt(static::$cipher, static::key(), $value, static::$mode, $iv), "\0");
|
$value = mcrypt_decrypt(static::$cipher, static::key(), $value, static::$mode, $iv);
|
||||||
|
|
||||||
|
return rtrim($value, "\0");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse an encrypted value into the input vector and the actual value.
|
* Parse an encrypted value into the input vector and the actual value.
|
||||||
*
|
*
|
||||||
* If the given value is not valid base64 data, an exception will be thrown.
|
|
||||||
*
|
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected static function parse($value)
|
protected static function parse($value)
|
||||||
{
|
{
|
||||||
if ( ! is_string($value))
|
if ($value === false)
|
||||||
{
|
{
|
||||||
throw new \Exception('Decryption error. Input value is not valid base64 data.');
|
throw new \Exception('Decryption error. Input value is not valid base64 data.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,9 +137,9 @@ public static function put($key, $value)
|
||||||
/**
|
/**
|
||||||
* Write an item to the session flash data.
|
* Write an item to the session flash data.
|
||||||
*
|
*
|
||||||
* Flash data only exists for the next request. After that, it will
|
* Flash data only exists for the next request. After that, it will be
|
||||||
* be removed from the session. Flash data is useful for temporary
|
* removed from the session. Flash data is useful for temporary status
|
||||||
* status or welcome messages.
|
* or welcome messages.
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* // Flash an item to the session
|
* // Flash an item to the session
|
||||||
|
@ -236,9 +236,6 @@ public static function age()
|
||||||
{
|
{
|
||||||
static::$session['last_activity'] = time();
|
static::$session['last_activity'] = time();
|
||||||
|
|
||||||
// To age the data, we will forget all of the old keys and then
|
|
||||||
// rewrite the newly flashed items to have old keys, which will
|
|
||||||
// be available for the next request.
|
|
||||||
foreach (static::$session['data'] as $key => $value)
|
foreach (static::$session['data'] as $key => $value)
|
||||||
{
|
{
|
||||||
if (strpos($key, ':old:') === 0) static::forget($key);
|
if (strpos($key, ':old:') === 0) static::forget($key);
|
||||||
|
|
|
@ -281,7 +281,7 @@ protected function validate_integer($attribute, $value)
|
||||||
*/
|
*/
|
||||||
protected function validate_size($attribute, $value, $parameters)
|
protected function validate_size($attribute, $value, $parameters)
|
||||||
{
|
{
|
||||||
return $this->get_size($attribute, $value) == $parameters[0];
|
return $this->size($attribute, $value) == $parameters[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -294,7 +294,7 @@ protected function validate_size($attribute, $value, $parameters)
|
||||||
*/
|
*/
|
||||||
protected function validate_between($attribute, $value, $parameters)
|
protected function validate_between($attribute, $value, $parameters)
|
||||||
{
|
{
|
||||||
return $this->get_size($attribute, $value) >= $parameters[0] and $this->get_size($attribute, $value) <= $parameters[1];
|
return $this->size($attribute, $value) >= $parameters[0] and $this->size($attribute, $value) <= $parameters[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -307,7 +307,7 @@ protected function validate_between($attribute, $value, $parameters)
|
||||||
*/
|
*/
|
||||||
protected function validate_min($attribute, $value, $parameters)
|
protected function validate_min($attribute, $value, $parameters)
|
||||||
{
|
{
|
||||||
return $this->get_size($attribute, $value) >= $parameters[0];
|
return $this->size($attribute, $value) >= $parameters[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -320,7 +320,7 @@ protected function validate_min($attribute, $value, $parameters)
|
||||||
*/
|
*/
|
||||||
protected function validate_max($attribute, $value, $parameters)
|
protected function validate_max($attribute, $value, $parameters)
|
||||||
{
|
{
|
||||||
return $this->get_size($attribute, $value) <= $parameters[0];
|
return $this->size($attribute, $value) <= $parameters[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -335,7 +335,7 @@ protected function validate_max($attribute, $value, $parameters)
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
protected function get_size($attribute, $value)
|
protected function size($attribute, $value)
|
||||||
{
|
{
|
||||||
if (is_numeric($value) and $this->has_rule($attribute, $this->numeric_rules))
|
if (is_numeric($value) and $this->has_rule($attribute, $this->numeric_rules))
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,10 +133,9 @@ protected static function name($name)
|
||||||
{
|
{
|
||||||
if (is_null(static::$composers)) static::$composers = require APP_PATH.'composers'.EXT;
|
if (is_null(static::$composers)) static::$composers = require APP_PATH.'composers'.EXT;
|
||||||
|
|
||||||
// The view's name may specified in several different ways in the
|
// The view's name may specified in several different ways in the composers
|
||||||
// composers file. The composer may simple have a string value,
|
// file. The composer may simple have a string value, which is the name.
|
||||||
// which is the name. Or, it may an array value in which a
|
// Or, it may an array value in which a "name" key exists.
|
||||||
// "name" key exists.
|
|
||||||
foreach (static::$composers as $key => $value)
|
foreach (static::$composers as $key => $value)
|
||||||
{
|
{
|
||||||
if ($name === $value or (is_array($value) and $name === Arr::get($value, 'name')))
|
if ($name === $value or (is_array($value) and $name === Arr::get($value, 'name')))
|
||||||
|
@ -174,10 +173,10 @@ public function render()
|
||||||
{
|
{
|
||||||
static::compose($this);
|
static::compose($this);
|
||||||
|
|
||||||
// All nested views and responses are evaluated before the
|
// All nested views and responses are evaluated before the main view.
|
||||||
// main view. This allows the assets used by these views to
|
// This allows the assets used by the nested views to be added to the
|
||||||
// be added to the asset container before the main view is
|
// asset container before the main view is evaluated and dumps the
|
||||||
// evaluated and dumps the links to the assets.
|
// links to the assets.
|
||||||
foreach ($this->data as &$data)
|
foreach ($this->data as &$data)
|
||||||
{
|
{
|
||||||
if ($data instanceof View or $data instanceof Response)
|
if ($data instanceof View or $data instanceof Response)
|
||||||
|
@ -188,9 +187,9 @@ public function render()
|
||||||
|
|
||||||
ob_start() and extract($this->data, EXTR_SKIP);
|
ob_start() and extract($this->data, EXTR_SKIP);
|
||||||
|
|
||||||
// If the view is a "Blade" view, we need to check the view for
|
// If the view is Bladed, we need to check the view for modifications
|
||||||
// modifications and get the path to the compiled view file.
|
// and get the path to the compiled view file. Otherwise, we'll just
|
||||||
// Otherwise, we'll just use the regular path to the view.
|
// use the regular path to the view.
|
||||||
$view = (strpos($this->path, BLADE_EXT) !== false) ? $this->compile() : $this->path;
|
$view = (strpos($this->path, BLADE_EXT) !== false) ? $this->compile() : $this->path;
|
||||||
|
|
||||||
try { include $view; } catch (Exception $e) { ob_get_clean(); throw $e; }
|
try { include $view; } catch (Exception $e) { ob_get_clean(); throw $e; }
|
||||||
|
|
Loading…
Reference in New Issue