function Debug::message

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

Provides debug function to Twig templates.

Handles 0, 1, or multiple arguments.

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.

Return value

void

See also

\Drupal\devel\DevelDumperManager::message()

File

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

Class

Debug
Provides the Devel debugging function within Twig templates.

Namespace

Drupal\devel\Twig\Extension

Code

public function message(\Twig_Environment $env, array $context, array $args = []) {
    if (!$env->isDebug()) {
        return;
    }
    // No arguments passed, display full Twig context.
    if (empty($args)) {
        $context_variables = $this->getContextVariables($context);
        $this->dumper
            ->message($context_variables, 'Twig context');
    }
    else {
        foreach ($args as $variable) {
            $this->dumper
                ->message($variable);
        }
    }
}