コード例 #1
0
 /**
  * Provides debug function to Twig templates.
  *
  * Handles 0, 1, or multiple arguments.
  *
  * @param \Twig_Environment $env
  *   The twig environment instance.
  * @param array $context
  *   An array of parameters passed to the template.
  * @param array $args
  *   An array of parameters passed the function.
  *
  * @return string
  *   String representation of the input variables.
  *
  * @see \Drupal\devel\DevelDumperManager::dump()
  */
 public function dump(\Twig_Environment $env, array $context, array $args = [])
 {
     if (!$env->isDebug()) {
         return;
     }
     ob_start();
     // No arguments passed, display full Twig context.
     if (empty($args)) {
         $context_variables = $this->getContextVariables($context);
         $this->dumper->dump($context_variables, 'Twig context');
     } else {
         foreach ($args as $variable) {
             $this->dumper->dump($variable);
         }
     }
     return ob_get_clean();
 }
コード例 #2
0
 /**
  * @return array
  */
 public function dump()
 {
     $this->dumper->dump('Test output');
     return ['#markup' => 'test'];
 }