Commit 6eadec2a authored by Avris's avatar Avris

v3.2

parent 09b0e22f
......@@ -14,6 +14,9 @@ class TwigModule implements Module
'params' => ['@container', '{@rootDir}/run/cache/{@env}/twig'],
'events' => ['cacheWarmup'],
],
'twig' => [
'resolve' => '@templater.twig',
],
]
];
}
......
......@@ -3,7 +3,6 @@ namespace Avris\Micrus\Twig;
use Avris\Micrus\Exception\NotFoundException;
use Avris\Micrus\Bootstrap\ContainerInterface;
use Avris\Micrus\Tool\Cache\CacheWarmupEvent;
use Avris\Micrus\View\Templater;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\Dumper\CliDumper;
......@@ -84,7 +83,7 @@ class TwigTemplater extends Templater
* @return string
* @throws NotFoundException
*/
public function render($vars)
public function render(array $vars)
{
return $this->twig->render($vars['_view'], $vars);
}
......@@ -92,13 +91,22 @@ class TwigTemplater extends Templater
public function hasTemplate($templateName)
{
try {
$this->twig->loadTemplate($templateName);
$this->twig->load($templateName);
return true;
} catch (\Twig_Error_Loader $e) {
return false;
}
}
/**
* @return \Twig_Environment
*/
public function getTwig()
{
return $this->twig;
}
public function onCacheWarmup()
{
foreach ($this->dirs as $dir) {
......@@ -108,7 +116,7 @@ class TwigTemplater extends Templater
foreach ($files as $filename => $file) {
if (!$file->isDir()) {
try {
$this->twig->loadTemplate(substr($filename, strlen($dir) + 1));
$this->twig->load(substr($filename, strlen($dir) + 1));
} catch (\Twig_Error $e) {}
}
}
......
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