refactoring.
This commit is contained in:
@@ -9,6 +9,14 @@ class Arr {
|
||||
* also be accessed using JavaScript "dot" style notation. Retrieving items nested
|
||||
* in multiple arrays is supported.
|
||||
*
|
||||
* <code>
|
||||
* // Get the "name" item from the array
|
||||
* $name = Arr::get(array('name' => 'Fred'), 'name');
|
||||
*
|
||||
* // Get the "age" item from the array, or return 25 if it doesn't exist
|
||||
* $name = Arr::get(array('name' => 'Fred'), 'age', 25);
|
||||
* </code>
|
||||
*
|
||||
* @param array $array
|
||||
* @param string $key
|
||||
* @param mixed $default
|
||||
@@ -38,6 +46,11 @@ class Arr {
|
||||
* a variable depth, such as configuration arrays. Like the Arr::get
|
||||
* method, JavaScript "dot" syntax is supported.
|
||||
*
|
||||
* <code>
|
||||
* // Set the "name" item to "Fred" in the array
|
||||
* Arr::set($array, 'name', 'Fred');
|
||||
* </code>
|
||||
*
|
||||
* @param array $array
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
|
||||
@@ -5,8 +5,6 @@ class Asset {
|
||||
/**
|
||||
* All of the instantiated asset containers.
|
||||
*
|
||||
* Asset containers are created through the container method, and are singletons.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $containers = array();
|
||||
@@ -36,6 +34,14 @@ class Asset {
|
||||
* Containers provide a convenient method of grouping assets while maintaining
|
||||
* expressive code and a clean API.
|
||||
*
|
||||
* <code>
|
||||
* // Get the default asset container
|
||||
* $container = Asset::container();
|
||||
*
|
||||
* // Get the "footer" asset container
|
||||
* $container = Asset::container('footer');
|
||||
* </code>
|
||||
*
|
||||
* @param string $container
|
||||
* @return Asset_Container
|
||||
*/
|
||||
@@ -54,6 +60,14 @@ class Asset {
|
||||
*
|
||||
* This provides a convenient API, allowing the develop to skip the "container"
|
||||
* method when using the default container.
|
||||
*
|
||||
* <code>
|
||||
* // Add a JavaScript file to the default container
|
||||
* Asset::script('jquery', 'js/jquery.js');
|
||||
*
|
||||
* // Get all of the styles from the default container
|
||||
* echo Asset::styles();
|
||||
* </code>
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
@@ -169,7 +183,7 @@ class Asset_Container {
|
||||
* @param array $attributes
|
||||
* @return void
|
||||
*/
|
||||
private function register($type, $name, $source, $dependencies, $attributes)
|
||||
protected function register($type, $name, $source, $dependencies, $attributes)
|
||||
{
|
||||
$dependencies = (array) $dependencies;
|
||||
|
||||
@@ -202,7 +216,7 @@ class Asset_Container {
|
||||
* @param string $group
|
||||
* @return string
|
||||
*/
|
||||
private function get_group($group)
|
||||
protected function get_group($group)
|
||||
{
|
||||
if ( ! isset($this->assets[$group]) or count($this->assets[$group]) == 0) return '';
|
||||
|
||||
@@ -245,7 +259,7 @@ class Asset_Container {
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
private function get_asset($group, $name)
|
||||
protected function get_asset($group, $name)
|
||||
{
|
||||
if ( ! isset($this->assets[$group][$name])) return '';
|
||||
|
||||
@@ -260,7 +274,7 @@ class Asset_Container {
|
||||
* @param array $assets
|
||||
* @return array
|
||||
*/
|
||||
private function arrange($assets)
|
||||
protected function arrange($assets)
|
||||
{
|
||||
list($original, $sorted) = array($assets, array());
|
||||
|
||||
@@ -285,7 +299,7 @@ class Asset_Container {
|
||||
* @param array $assets
|
||||
* @return void
|
||||
*/
|
||||
private function evaluate_asset($asset, $value, $original, &$sorted, &$assets)
|
||||
protected function evaluate_asset($asset, $value, $original, &$sorted, &$assets)
|
||||
{
|
||||
// If the asset has no more dependencies, we can add it to the sorted list
|
||||
// and remove it from the array of assets. Otherwise, we will not verify
|
||||
@@ -327,7 +341,7 @@ class Asset_Container {
|
||||
* @param array $assets
|
||||
* @return bool
|
||||
*/
|
||||
private function dependency_is_valid($asset, $dependency, $original, $assets)
|
||||
protected function dependency_is_valid($asset, $dependency, $original, $assets)
|
||||
{
|
||||
if ( ! isset($original[$dependency])) return false;
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class Caller {
|
||||
return $this->finish($route, $response);
|
||||
}
|
||||
|
||||
if ( ! is_null($response = $route->call($this->container)))
|
||||
if ( ! is_null($response = $route->call()))
|
||||
{
|
||||
if (is_array($response)) $response = $this->delegator->delegate($route, $response);
|
||||
|
||||
@@ -83,7 +83,7 @@ class Caller {
|
||||
{
|
||||
$before = array_merge(array('before'), $route->filters('before'));
|
||||
|
||||
return $this->filterer->filter($before, array($this->container), true);
|
||||
return $this->filterer->filter($before, array(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ class Caller {
|
||||
{
|
||||
if ( ! $response instanceof Response) $response = new Response($response);
|
||||
|
||||
$this->filterer->filter(array_merge($route->filters('after'), array('after')), array($this->container, $response));
|
||||
$this->filterer->filter(array_merge($route->filters('after'), array('after')), array($response));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -52,17 +52,15 @@ class Route {
|
||||
/**
|
||||
* Call the route closure.
|
||||
*
|
||||
* If no closure is defined for the route, null will be returned. The IoC container instance will be
|
||||
* passed to the route closure so it has access to all of the framework components.
|
||||
* If no closure is defined for the route, null will be returned.
|
||||
*
|
||||
* @param Container $container
|
||||
* @return mixed
|
||||
*/
|
||||
public function call(Container $container)
|
||||
public function call()
|
||||
{
|
||||
if (is_null($closure = $this->find_closure())) return;
|
||||
|
||||
return call_user_func_array($closure, array_merge($this->parameters, array($container)));
|
||||
return call_user_func_array($closure, $this->parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user