aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/3rdparty/Twig/Extension/Debug.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-02 22:43:56 +0200
committerNicolas LÅ“uillet <nicolas.loeuillet@gmail.com>2013-08-02 22:43:56 +0200
commit8069e235fd2971675ee5fc05026ffa9bce5cbbb7 (patch)
tree872eaed228b5e1b031c21770fba1701106a52a39 /inc/3rdparty/Twig/Extension/Debug.php
parent45161a64026cec35fcf07659508143a6f55ddf57 (diff)
downloadwallabag-8069e235fd2971675ee5fc05026ffa9bce5cbbb7.tar.gz
wallabag-8069e235fd2971675ee5fc05026ffa9bce5cbbb7.tar.zst
wallabag-8069e235fd2971675ee5fc05026ffa9bce5cbbb7.zip
move Twig in 3rdparty
Diffstat (limited to 'inc/3rdparty/Twig/Extension/Debug.php')
-rw-r--r--inc/3rdparty/Twig/Extension/Debug.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/inc/3rdparty/Twig/Extension/Debug.php b/inc/3rdparty/Twig/Extension/Debug.php
new file mode 100644
index 00000000..e3a85bfe
--- /dev/null
+++ b/inc/3rdparty/Twig/Extension/Debug.php
@@ -0,0 +1,71 @@
1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) 2011 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 */
11class Twig_Extension_Debug extends Twig_Extension
12{
13 /**
14 * Returns a list of global functions to add to the existing list.
15 *
16 * @return array An array of global functions
17 */
18 public function getFunctions()
19 {
20 // dump is safe if var_dump is overridden by xdebug
21 $isDumpOutputHtmlSafe = extension_loaded('xdebug')
22 // false means that it was not set (and the default is on) or it explicitly enabled
23 && (false === ini_get('xdebug.overload_var_dump') || ini_get('xdebug.overload_var_dump'))
24 // false means that it was not set (and the default is on) or it explicitly enabled
25 // xdebug.overload_var_dump produces HTML only when html_errors is also enabled
26 && (false === ini_get('html_errors') || ini_get('html_errors'))
27 || 'cli' === php_sapi_name()
28 ;
29
30 return array(
31 new Twig_SimpleFunction('dump', 'twig_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
32 );
33 }
34
35 /**
36 * Returns the name of the extension.
37 *
38 * @return string The extension name
39 */
40 public function getName()
41 {
42 return 'debug';
43 }
44}
45
46function twig_var_dump(Twig_Environment $env, $context)
47{
48 if (!$env->isDebug()) {
49 return;
50 }
51
52 ob_start();
53
54 $count = func_num_args();
55 if (2 === $count) {
56 $vars = array();
57 foreach ($context as $key => $value) {
58 if (!$value instanceof Twig_Template) {
59 $vars[$key] = $value;
60 }
61 }
62
63 var_dump($vars);
64 } else {
65 for ($i = 2; $i < $count; $i++) {
66 var_dump(func_get_arg($i));
67 }
68 }
69
70 return ob_get_clean();
71}