Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
DumpExtension.php
01 <?php
02
03 /*
04 * This file is part of the Symfony package.
05 *
06 * (c) Fabien Potencier <fabien@symfony.com>
07 *
08 * For the full copyright and license information, please view the LICENSE
09 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Bridge\Twig\Extension;
13
14 use Symfony\Bridge\Twig\TokenParser\DumpTokenParser;
15 use Symfony\Component\VarDumper\Cloner\ClonerInterface;
16 use Symfony\Component\VarDumper\Dumper\HtmlDumper;
17
18 /**
19 * Provides integration of the dump() function with Twig.
20 *
21 * @author Nicolas Grekas <p@tchwork.com>
22 */
23 class DumpExtension extends \Twig_Extension
24 {
25 private $cloner;
26
27 public function __construct(ClonerInterface $cloner)
28 {
29 $this->cloner = $cloner;
30 }
31
32 public function getFunctions()
33 {
34 return array(
35 new \Twig_SimpleFunction('dump', array($this, 'dump'), array('is_safe' => array('html'), 'needs_context' => true, 'needs_environment' => true)),
36 );
37 }
38
39 public function getTokenParsers()
40 {
41 return array(new DumpTokenParser());
42 }
43
44 public function getName()
45 {
46 return 'dump';
47 }
48
49 public function dump(\Twig_Environment $env, $context)
50 {
51 if (!$env->isDebug()) {
52 return;
53 }
54
55 if (2 === func_num_args()) {
56 $vars = array();
57 foreach ($context as $key => $value) {
58 if (!$value instanceof \Twig_Template) {
59 $vars[$key] = $value;
60 }
61 }
62
63 $vars = array($vars);
64 } else {
65 $vars = func_get_args();
66 unset($vars[0], $vars[1]);
67 }
68
69 $dump = fopen('php://memory', 'r+b');
70 $dumper = new HtmlDumper($dump, $env->getCharset());
71
72 foreach ($vars as $value) {
73 $dumper->dump($this->cloner->cloneVar($value));
74 }
75 rewind($dump);
76
77 return stream_get_contents($dump);
78 }
79 }
80