some small refactorings and cleanup.
This commit is contained in:
parent
b71ecb4363
commit
32989d39c8
|
@ -261,6 +261,7 @@ protected function evaluate_asset($asset, $value, $original, &$sorted, &$assets)
|
||||||
if (count($assets[$asset]['dependencies']) == 0)
|
if (count($assets[$asset]['dependencies']) == 0)
|
||||||
{
|
{
|
||||||
$sorted[$asset] = $value;
|
$sorted[$asset] = $value;
|
||||||
|
|
||||||
unset($assets[$asset]);
|
unset($assets[$asset]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -270,6 +271,7 @@ protected function evaluate_asset($asset, $value, $original, &$sorted, &$assets)
|
||||||
if ( ! $this->dependency_is_valid($asset, $dependency, $original, $assets))
|
if ( ! $this->dependency_is_valid($asset, $dependency, $original, $assets))
|
||||||
{
|
{
|
||||||
unset($assets[$asset]['dependencies'][$key]);
|
unset($assets[$asset]['dependencies'][$key]);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,29 +3,16 @@
|
||||||
class Blade {
|
class Blade {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rewrites the specified file containing Blade pseudo-code into valid PHP.
|
* Compiles the specified file containing Blade pseudo-code into valid PHP.
|
||||||
*
|
*
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function parse($path)
|
public static function compile($path)
|
||||||
{
|
{
|
||||||
return static::parse_string(file_get_contents($path));
|
$value = file_get_contents($path);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
return static::closings(static::openings(static::echos($value)));
|
||||||
* Rewrites the specified string containing Blade pseudo-code into valid PHP.
|
|
||||||
*
|
|
||||||
* @param string $value
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function parse_string($value)
|
|
||||||
{
|
|
||||||
$value = static::echos($value);
|
|
||||||
$value = static::openings($value);
|
|
||||||
$value = static::closings($value);
|
|
||||||
|
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -194,16 +194,18 @@ protected function execute(PDOStatement $statement, $bindings)
|
||||||
{
|
{
|
||||||
$result = $statement->execute($bindings);
|
$result = $statement->execute($bindings);
|
||||||
|
|
||||||
if (strpos(strtoupper($statement->queryString), 'SELECT') === 0)
|
$sql = strtoupper($statement->queryString);
|
||||||
|
|
||||||
|
if (strpos($sql, 'SELECT') === 0)
|
||||||
{
|
{
|
||||||
return $statement->fetchAll(PDO::FETCH_CLASS, 'stdClass');
|
return $statement->fetchAll(PDO::FETCH_CLASS, 'stdClass');
|
||||||
}
|
}
|
||||||
elseif (strpos(strtoupper($statement->queryString), 'INSERT') === 0)
|
elseif (strpos($sql, 'UPDATE') === 0 or strpos($sql, 'DELETE') === 0)
|
||||||
{
|
{
|
||||||
return $result;
|
return $statement->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $statement->rowCount();
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -252,7 +252,9 @@ protected function element($element, $text, $page, $disabler)
|
||||||
// the current URI, this makes pretty good sense.
|
// the current URI, this makes pretty good sense.
|
||||||
list($uri, $secure) = array(Request::uri(), Request::secure());
|
list($uri, $secure) = array(Request::uri(), Request::secure());
|
||||||
|
|
||||||
return HTML::link($uri.$this->appendage($element, $page), $text, array('class' => $class), $secure);
|
$appendage = $this->appendage($element, $page);
|
||||||
|
|
||||||
|
return HTML::link($uri.$appendage, $text, array('class' => $class), $secure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,34 +101,38 @@ public function call()
|
||||||
// a controller, the controller will only call its own filters.
|
// 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)))
|
$response = Filter::run($before, array(), true);
|
||||||
{
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ! is_null($response = $this->response()))
|
if (is_null($response) and ! is_null($response = $this->response()))
|
||||||
{
|
{
|
||||||
if ($response instanceof Delegate)
|
if ($response instanceof Delegate)
|
||||||
{
|
{
|
||||||
$response = Controller::call($response->destination, $this->parameters);
|
$response = Controller::call($response->destination, $this->parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)
|
|
||||||
{
|
|
||||||
$response = new Response($response);
|
|
||||||
}
|
|
||||||
|
|
||||||
$filters = array_merge($this->filters('after'), array('after'));
|
|
||||||
|
|
||||||
Filter::run($filters, array($response));
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response::error('404');
|
// If we still don't have a response, we're out of options and
|
||||||
|
// will use the 404 response. We will still let the response
|
||||||
|
// hit the after filter in case the developer is doing any
|
||||||
|
// logging or other work where every response is needed.
|
||||||
|
if (is_null($response))
|
||||||
|
{
|
||||||
|
$response = Response::error('404');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
$response = new Response($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
$filters = array_merge($this->filters('after'), array('after'));
|
||||||
|
|
||||||
|
Filter::run($filters, array($response));
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -153,6 +153,7 @@ 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.
|
||||||
|
// This should make the route look something like: "user(\.(json|xml|html))?"
|
||||||
if ( ! is_null($formats = $this->provides($callback)))
|
if ( ! is_null($formats = $this->provides($callback)))
|
||||||
{
|
{
|
||||||
$key .= '(\.('.implode('|', $formats).'))?';
|
$key .= '(\.('.implode('|', $formats).'))?';
|
||||||
|
|
|
@ -278,7 +278,9 @@ public static function close()
|
||||||
// driver must do its garbage collection manually. Alternatively, some
|
// driver must do its garbage collection manually. Alternatively, some
|
||||||
// drivers such as APC and Memcached are not required to manually
|
// drivers such as APC and Memcached are not required to manually
|
||||||
// clean up their sessions.
|
// clean up their sessions.
|
||||||
if (mt_rand(1, $config['sweepage'][1]) <= $config['sweepage'][0] and static::$driver instanceof Drivers\Sweeper)
|
$sweep = (mt_rand(1, $config['sweepage'][1]) <= $config['sweepage'][0]);
|
||||||
|
|
||||||
|
if ($sweep and static::$driver instanceof Drivers\Sweeper)
|
||||||
{
|
{
|
||||||
static::$driver->sweep(time() - ($config['lifetime'] * 60));
|
static::$driver->sweep(time() - ($config['lifetime'] * 60));
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,8 +163,6 @@ protected function check($attribute, $rule)
|
||||||
{
|
{
|
||||||
list($rule, $parameters) = $this->parse($rule);
|
list($rule, $parameters) = $this->parse($rule);
|
||||||
|
|
||||||
// Verify that the attribute and rule combination is actually
|
|
||||||
// validatable before attempting to call the validation rule.
|
|
||||||
$value = Arr::get($this->attributes, $attribute);
|
$value = Arr::get($this->attributes, $attribute);
|
||||||
|
|
||||||
if ( ! $this->validatable($rule, $attribute, $value)) return;
|
if ( ! $this->validatable($rule, $attribute, $value)) return;
|
||||||
|
|
|
@ -123,8 +123,7 @@ public static function of($name, $data = array())
|
||||||
/**
|
/**
|
||||||
* Find the key for a view by name.
|
* Find the key for a view by name.
|
||||||
*
|
*
|
||||||
* The view's key can be used to create instances of the view through the typical
|
* The view "key" is the string that should be passed into the "make" method.
|
||||||
* methods available on the view factory.
|
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -133,9 +132,6 @@ 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 composers
|
|
||||||
// file. The composer may simple have a string value, which is the name.
|
|
||||||
// Or, it may an array value in which a "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')))
|
||||||
|
@ -215,7 +211,7 @@ protected function compile()
|
||||||
// without re-compiling.
|
// without re-compiling.
|
||||||
if ((file_exists($compiled) and filemtime($this->path) > filemtime($compiled)) or ! file_exists($compiled))
|
if ((file_exists($compiled) and filemtime($this->path) > filemtime($compiled)) or ! file_exists($compiled))
|
||||||
{
|
{
|
||||||
file_put_contents($compiled, Blade::parse($this->path));
|
file_put_contents($compiled, Blade::compile($this->path));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $compiled;
|
return $compiled;
|
||||||
|
|
Loading…
Reference in New Issue