function Debug::breakpoint

Same name in other branches
  1. 5.x src/Twig/Extension/Debug.php \Drupal\devel\Twig\Extension\Debug::breakpoint()

Provides XDebug integration for Twig templates.

To use this features simply put the following statement in the template of interest:


{{ devel_breakpoint() }}

When the template is evaluated is made a call to a dedicated method in devel twig debug extension in which is used xdebug_break(), that emits a breakpoint to the debug client (the debugger break on the specific line as if a normal file/line breakpoint was set on this line). In this way you'll be able to inspect any variables available in the template (environment, context, specific variables etc..) in your IDE.

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.

File

src/Twig/Extension/Debug.php, line 207

Class

Debug
Provides the Devel debugging function within Twig templates.

Namespace

Drupal\devel\Twig\Extension

Code

public function breakpoint(\Twig_Environment $env, array $context, array $args = []) {
    if (!$env->isDebug()) {
        return;
    }
    if (function_exists('xdebug_break')) {
        xdebug_break();
    }
}