Tentatively added twig panel to debugbar - currently has issues with "processpage" twig calls used by modular

This commit is contained in:
Andy Miller
2014-10-22 21:14:11 -06:00
parent 8950e6661f
commit bb0ee34082
3 changed files with 16 additions and 4 deletions

View File

@@ -42,5 +42,6 @@ assets: # Configuration for Assets Manager (JS, C
debugger:
enabled: false # Enable Grav debugger and following settings
twig: true # Enable debugging of Twig templates
shutdown:
close_connection: true # Close the connection before calling onShutdown(). false for debugging

View File

@@ -186,7 +186,7 @@ class Grav extends Container
}
$this['assets']->init();
$debugger->addAssets();
$this->fireEvent('onAssetsInitialized');
$debugger->startTimer('twig', 'Twig');
@@ -201,6 +201,7 @@ class Grav extends Container
$this->fireEvent('onPageInitialized');
$debugger->addAssets();
// Process whole page as required
$debugger->startTimer('render', 'Render');
@@ -208,6 +209,7 @@ class Grav extends Container
$this->fireEvent('onOutputGenerated');
$debugger->stopTimer('render');
// Set the header type
$this->header();
echo $this->output;

View File

@@ -70,6 +70,7 @@ class Twig
$config = $this->grav['config'];
/** @var UniformResourceLocator $locator */
$locator = $this->grav['locator'];
$debugger = $this->grav['debugger'];
$this->twig_paths = $locator->findResources('theme://templates');
$this->grav->fireEvent('onTwigTemplatePaths');
@@ -84,6 +85,11 @@ class Twig
}
$this->twig = new \Twig_Environment($loader_chain, $params);
if ($debugger->enabled() && $config->get('system.debugger.twig')) {
$this->twig = new \DebugBar\Bridge\Twig\TraceableTwigEnvironment($this->twig);
$collector = new \DebugBar\Bridge\Twig\TwigCollector($this->twig);
$debugger->addCollector($collector);
}
$this->grav->fireEvent('onTwigInitialized');
// set default date format if set in config
@@ -95,6 +101,8 @@ class Twig
$this->twig->addExtension(new \Twig_Extension_Debug());
}
$this->twig->addExtension(new TwigExtension());
$this->grav->fireEvent('onTwigExtensions');
$baseUrlAbsolute = $config->get('system.base_url_absolute');
@@ -117,7 +125,6 @@ class Twig
'taxonomy' => $this->grav['taxonomy'],
'browser' => $this->grav['browser'],
);
}
}
@@ -170,15 +177,17 @@ class Twig
$twig_vars['media'] = $item->media();
$twig_vars['header'] = $item->header();
$local_twig = clone($this->twig);
// Get Twig template layout
if ($item->modularTwig()) {
$twig_vars['content'] = $content;
$template = $item->template() . TEMPLATE_EXT;
$output = $this->twig->render($template, $twig_vars);
$output = $local_twig->render($template, $twig_vars);
} else {
$name = '@Page:' . $item->path();
$this->setTemplate($name, $content);
$output = $this->twig->render($name, $twig_vars);
$output = $local_twig->render($name, $twig_vars);
}
return $output;