mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-25 02:02:57 +01:00
Use Renderer::load()
to insert templates and load controllers
This commit is contained in:
parent
7ed745333a
commit
7f1961eeed
@ -161,6 +161,10 @@ class Template
|
||||
*/
|
||||
public function insert($name, array $vars = array())
|
||||
{
|
||||
if (!$this->rendering) {
|
||||
throw new RuntimeException(__METHOD__ . ' is allowed only in rendering context');
|
||||
}
|
||||
|
||||
if ($name[0] === '_') {
|
||||
$name = 'partials' . DS . substr($name, 1);
|
||||
}
|
||||
@ -171,9 +175,7 @@ class Template
|
||||
throw new RuntimeException('Template ' . $name . ' not found');
|
||||
}
|
||||
|
||||
extract(array_merge($this->vars, $vars));
|
||||
|
||||
include $filename;
|
||||
Renderer::load($filename, array_merge($this->vars, $vars), $this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -244,15 +246,11 @@ class Template
|
||||
*/
|
||||
protected function loadController()
|
||||
{
|
||||
if ($this->rendering) {
|
||||
throw new RuntimeException(__METHOD__ . ' not allowed while rendering');
|
||||
}
|
||||
|
||||
$controllerFile = $this->path() . 'controllers' . DS . $this->name . '.php';
|
||||
|
||||
if (FileSystem::exists($controllerFile)) {
|
||||
extract($this->vars);
|
||||
$this->vars = array_merge($this->vars, (array) include $controllerFile);
|
||||
$this->vars = array_merge($this->vars, (array) Renderer::load($controllerFile, $this->vars, $this));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user