Minor optimizations to TwigFactory

This commit is contained in:
Chris Kankiewicz
2020-05-26 13:39:27 -07:00
parent ac3b7d0c77
commit 209d108e6f

View File

@@ -40,24 +40,18 @@ class TwigFactory
{
$twig = new Twig(new FilesystemLoader(
$this->container->get('views_path')
));
), ['cache' => $this->container->get('view_cache')]);
$twig->getEnvironment()->setCache(
$this->container->get('view_cache')
);
$environment = $twig->getEnvironment();
$core = $environment->getExtension(CoreExtension::class);
$twig->getEnvironment()->getExtension(CoreExtension::class)->setDateFormat(
$this->container->get('date_format'), '%d days'
);
$twig->getEnvironment()->getExtension(CoreExtension::class)->setTimezone(
$this->container->get('timezone')
);
$core->setDateFormat($this->container->get('date_format'), '%d days');
$core->setTimezone($this->container->get('timezone'));
foreach ($this->container->get('view_functions') as $function) {
$function = $this->callableResolver->resolve($function);
$twig->getEnvironment()->addFunction(
$environment->addFunction(
new TwigFunction($function->name(), $function)
);
}