diff --git a/src/Templating/TwigEngine.php b/src/Templating/TwigEngine.php index 8c66185..24ba484 100644 --- a/src/Templating/TwigEngine.php +++ b/src/Templating/TwigEngine.php @@ -4,6 +4,8 @@ use Pyrite\Container\Container; use Pyrite\Templating\Twig\Extension; +use Symfony\Bridge\Twig\Extension\DumpExtension; +use Symfony\Component\VarDumper\Cloner\VarCloner; class TwigEngine implements Engine { @@ -13,12 +15,17 @@ public function __construct(Container $container) { $rootDir = $container->getParameter('root_dir'); $productionMode = $container->getParameter('production_mode'); + $debug = !$productionMode; $loader = new \Twig_Loader_Filesystem($rootDir); $this->twig = new \Twig_Environment($loader, array( 'cache' => $rootDir . '/tmp', - 'debug' => !($productionMode === true) + 'debug' => $debug )); + + if ($debug && class_exists(VarCloner::class) && class_exists(DumpExtension::class)) { + $this->twig->addExtension(new DumpExtension(new VarCloner())); + } } public function extendTwig(Extension $extension)