mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-25 02:02:57 +01:00
Cleanup code
This commit is contained in:
parent
e7c80c422b
commit
4ab20712a1
@ -6,13 +6,6 @@ use Closure;
|
||||
|
||||
class Renderer
|
||||
{
|
||||
/**
|
||||
* Renderer instance
|
||||
*
|
||||
* @var Renderer
|
||||
*/
|
||||
protected static $instance;
|
||||
|
||||
/**
|
||||
* Load a script passing variables and binding to given instance and context
|
||||
*
|
||||
@ -25,10 +18,7 @@ class Renderer
|
||||
*/
|
||||
public static function load($filename, array $vars, $instance, $context = null)
|
||||
{
|
||||
if (is_null(static::$instance)) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
$closure = static::$instance->getClosure($instance, $context);
|
||||
$closure = static::getClosure($instance, $context);
|
||||
return $closure($filename, $vars);
|
||||
}
|
||||
|
||||
@ -40,7 +30,7 @@ class Renderer
|
||||
*
|
||||
* @return Closure
|
||||
*/
|
||||
protected function getClosure($instance, $context = null)
|
||||
protected static function getClosure($instance, $context = null)
|
||||
{
|
||||
return Closure::bind(function ($_filename, array $_vars) {
|
||||
extract($_vars);
|
||||
|
@ -36,7 +36,7 @@ class TemplateHelpers
|
||||
* @param string $name
|
||||
* @param callable $helper
|
||||
*/
|
||||
public static function add($name, $helper)
|
||||
public static function add($name, callable $helper)
|
||||
{
|
||||
if (static::has($name)) {
|
||||
throw new RuntimeException('Template helper ' . $name . ' is already defined');
|
||||
@ -44,9 +44,6 @@ class TemplateHelpers
|
||||
if (method_exists(Template::class, $name)) {
|
||||
throw new LogicException('Template helpers must not conflict with ' . Template::class . ' methods. Invalid name ' . $name);
|
||||
}
|
||||
if (!is_callable($helper)) {
|
||||
throw new LogicException('Template helper ' . $name . ' must be callable');
|
||||
}
|
||||
static::$helpers[$name] = $helper;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user