function Debug::doDump
Same name in other branches
- 4.x src/Twig/Extension/Debug.php \Drupal\devel\Twig\Extension\Debug::doDump()
Writes the debug information for Twig templates.
Parameters
\Twig\Environment $env: The twig environment instance.
array $context: An array of parameters passed to the template.
array $args: An array of parameters passed the function.
string $plugin_id: The plugin id. Defaults to null.
Return value
false|string|null String representation of the input variables, or null if twig_debug mode is tunred off.
2 calls to Debug::doDump()
- Debug::dump in src/
Twig/ Extension/ Debug.php - Provides debug function to Twig templates.
- Debug::kint in src/
Twig/ Extension/ Debug.php - Similar to dump() but always uses the kint dumper if available.
File
-
src/
Twig/ Extension/ Debug.php, line 107
Class
- Debug
- Provides the Devel debugging function within Twig templates.
Namespace
Drupal\devel\Twig\ExtensionCode
private function doDump(Environment $env, array $context, array $args = [], $plugin_id = NULL) : false|string|null {
if (!$env->isDebug()) {
return NULL;
}
ob_start();
// No arguments passed, display full Twig context.
if ($args === []) {
$context_variables = $this->getContextVariables($context);
$this->dumper
->dump($context_variables, 'Twig context', $plugin_id);
}
else {
$parameters = $this->guessTwigFunctionParameters();
foreach ($args as $index => $variable) {
$name = empty($parameters[$index]) ? NULL : $parameters[$index];
$this->dumper
->dump($variable, $name, $plugin_id);
}
}
return ob_get_clean();
}