ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Debug.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
16 {
17  public function getFunctions()
18  {
19  // dump is safe if var_dump is overridden by xdebug
20  $isDumpOutputHtmlSafe = extension_loaded('xdebug')
21  // false means that it was not set (and the default is on) or it explicitly enabled
22  && (false === ini_get('xdebug.overload_var_dump') || ini_get('xdebug.overload_var_dump'))
23  // false means that it was not set (and the default is on) or it explicitly enabled
24  // xdebug.overload_var_dump produces HTML only when html_errors is also enabled
25  && (false === ini_get('html_errors') || ini_get('html_errors'))
26  || 'cli' === PHP_SAPI
27  ;
28 
29  return array(
30  new Twig_SimpleFunction('dump', 'twig_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
31  );
32  }
33 
34  public function getName()
35  {
36  return 'debug';
37  }
38 }
39 
41 {
42  if (!$env->isDebug()) {
43  return;
44  }
45 
46  ob_start();
47 
48  $count = func_num_args();
49  if (2 === $count) {
50  $vars = array();
51  foreach ($context as $key => $value) {
52  if (!$value instanceof Twig_Template) {
53  $vars[$key] = $value;
54  }
55  }
56 
57  var_dump($vars);
58  } else {
59  for ($i = 2; $i < $count; ++$i) {
60  var_dump(func_get_arg($i));
61  }
62  }
63 
64  return ob_get_clean();
65 }
66 
67 class_alias('Twig_Extension_Debug', 'Twig\Extension\DebugExtension', false);
Represents a template function.
$context
Definition: webdav.php:25
isDebug()
Checks if debug mode is enabled.
$env
getFunctions()
Returns a list of functions to add to the existing list.
Definition: Debug.php:17
getName()
Returns the name of the extension.
Definition: Debug.php:34
Default base class for compiled templates.
Definition: Template.php:24
$i
Definition: disco.tpl.php:19
Stores the Twig configuration.
Definition: Environment.php:17
$key
Definition: croninfo.php:18
twig_var_dump(Twig_Environment $env, $context)
Definition: Debug.php:40