Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DebugExtension.php

function DebugExtension::dump

Same name in this branch
  1. 11.1.x vendor/twig/twig/src/Extension/DebugExtension.php \Twig\Extension\DebugExtension::dump()

Dumps information about variables using Symfony VarDumper.

Parameters

\Twig\Environment $env: The Twig environment.

array $context: Variables from the Twig template.

array $variables: (optional) Variable(s) to dump.

File

core/lib/Drupal/Core/Template/DebugExtension.php, line 50

Class

DebugExtension
A class providing Drupal Twig Debug extension.

Namespace

Drupal\Core\Template

Code

public static function dump(Environment $env, array $context, ...$variables) : void {
    if (!$env->isDebug()) {
        return;
    }
    if (class_exists(self::SYMFONY_VAR_DUMPER_CLASS)) {
        if (func_num_args() === 2) {
            call_user_func(self::SYMFONY_VAR_DUMPER_CLASS . '::dump', $context);
        }
        else {
            array_walk($variables, self::SYMFONY_VAR_DUMPER_CLASS . '::dump');
        }
    }
    else {
        throw new \LogicException('Could not dump the variable because symfony/var-dumper component is not installed.');
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal