Refactor the view class method order and comments.
This commit is contained in:
parent
6590b54f44
commit
d1d4ac1056
|
@ -136,34 +136,13 @@ private function compose()
|
||||||
{
|
{
|
||||||
$composer = static::$composers[$this->module][$this->view];
|
$composer = static::$composers[$this->module][$this->view];
|
||||||
|
|
||||||
if ( ! is_null($composer = $this->find_composer_handler($composer)))
|
if ( ! is_null($composer = $this->find_composer_function($composer)))
|
||||||
{
|
{
|
||||||
call_user_func($composer, $this);
|
call_user_func($composer, $this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the composer handler / function in a composer definition.
|
|
||||||
*
|
|
||||||
* If the composer value itself is callable, it will be returned, otherwise the
|
|
||||||
* first callable value in the composer array will be returned.
|
|
||||||
*
|
|
||||||
* @param mixed $composer
|
|
||||||
* @return Closure
|
|
||||||
*/
|
|
||||||
private function find_composer_handler($composer)
|
|
||||||
{
|
|
||||||
if (is_string($composer)) return;
|
|
||||||
|
|
||||||
if (is_callable($composer)) return $composer;
|
|
||||||
|
|
||||||
foreach ($composer as $value)
|
|
||||||
{
|
|
||||||
if (is_callable($value)) return $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the view composers for a given module.
|
* Load the view composers for a given module.
|
||||||
*
|
*
|
||||||
|
@ -179,6 +158,28 @@ private static function load_composers($module)
|
||||||
static::$composers[$module] = (file_exists($composers)) ? require $composers : array();
|
static::$composers[$module] = (file_exists($composers)) ? require $composers : array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the composer function in a composer definition.
|
||||||
|
*
|
||||||
|
* If the composer value itself is callable, it will be returned, otherwise the
|
||||||
|
* first callable value in the composer array will be returned. If the composer
|
||||||
|
* value is a string, it is simply a view name being defined.
|
||||||
|
*
|
||||||
|
* @param mixed $composer
|
||||||
|
* @return Closure
|
||||||
|
*/
|
||||||
|
private function find_composer_function($composer)
|
||||||
|
{
|
||||||
|
if (is_string($composer)) return;
|
||||||
|
|
||||||
|
if (is_callable($composer)) return $composer;
|
||||||
|
|
||||||
|
foreach ($composer as $value)
|
||||||
|
{
|
||||||
|
if (is_callable($value)) return $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the parsed content of the view.
|
* Get the parsed content of the view.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue