Commit 32989d39 by Taylor Otwell

some small refactorings and cleanup.

parent b71ecb43
......@@ -261,6 +261,7 @@ class Asset_Container {
if (count($assets[$asset]['dependencies']) == 0)
{
$sorted[$asset] = $value;
unset($assets[$asset]);
}
else
......@@ -270,6 +271,7 @@ class Asset_Container {
if ( ! $this->dependency_is_valid($asset, $dependency, $original, $assets))
{
unset($assets[$asset]['dependencies'][$key]);
continue;
}
......
......@@ -3,29 +3,16 @@
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
* @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);
/**
* 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;
return static::closings(static::openings(static::echos($value)));
}
/**
......
......@@ -194,16 +194,18 @@ class Connection {
{
$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');
}
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 @@ class Paginator {
// the current URI, this makes pretty good sense.
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 @@ class Route {
// a controller, the controller will only call its own filters.
$before = array_merge(array('before'), $this->filters('before'));
if ( ! is_null($response = Filter::run($before, array(), true)))
{
return $response;
}
$response = Filter::run($before, array(), true);
if ( ! is_null($response = $this->response()))
if (is_null($response) and ! is_null($response = $this->response()))
{
if ($response instanceof Delegate)
{
$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);
}
// 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');
}
$filters = array_merge($this->filters('after'), array('after'));
// 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);
}
Filter::run($filters, array($response));
$filters = array_merge($this->filters('after'), array('after'));
return $response;
}
Filter::run($filters, array($response));
return Response::error('404');
return $response;
}
/**
......
......@@ -153,6 +153,7 @@ class Router {
foreach (explode(', ', $keys) as $key)
{
// 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)))
{
$key .= '(\.('.implode('|', $formats).'))?';
......
......@@ -278,7 +278,9 @@ class Manager {
// driver must do its garbage collection manually. Alternatively, some
// drivers such as APC and Memcached are not required to manually
// 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));
}
......
......@@ -163,8 +163,6 @@ class Validator {
{
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);
if ( ! $this->validatable($rule, $attribute, $value)) return;
......
......@@ -123,8 +123,7 @@ class View {
/**
* Find the key for a view by name.
*
* The view's key can be used to create instances of the view through the typical
* methods available on the view factory.
* The view "key" is the string that should be passed into the "make" method.
*
* @param string $name
* @return string
......@@ -133,9 +132,6 @@ class View {
{
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)
{
if ($name === $value or (is_array($value) and $name === Arr::get($value, 'name')))
......@@ -215,7 +211,7 @@ class View {
// without re-compiling.
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;
......
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