Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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 use Twig\Environment;
18 use Twig\Extension\AbstractExtension;
19 use Twig\Template;
20 use Twig\TwigFunction;
21
22 /**
23 * Provides integration of the dump() function with Twig.
24 *
25 * @author Nicolas Grekas <p@tchwork.com>
26 */
27 class DumpExtension extends AbstractExtension
28 {
29 private $cloner;
30 private $dumper;
31
32 public function __construct(ClonerInterface $cloner, HtmlDumper $dumper = null)
33 {
34 $this->cloner = $cloner;
35 $this->dumper = $dumper;
36 }
37
38 public function getFunctions()
39 {
40 return [
41 new TwigFunction('dump', [$this, 'dump'], ['is_safe' => ['html'], 'needs_context' => true, 'needs_environment' => true]),
42 ];
43 }
44
45 public function getTokenParsers()
46 {
47 return [new DumpTokenParser()];
48 }
49
50 public function getName()
51 {
52 return 'dump';
53 }
54
55 public function dump(Environment $env, $context)
56 {
57 if (!$env->isDebug()) {
58 return null;
59 }
60
61 if (2 === \func_num_args()) {
62 $vars = [];
63 foreach ($context as $key => $value) {
64 if (!$value instanceof Template) {
65 $vars[$key] = $value;
66 }
67 }
68
69 $vars = [$vars];
70 } else {
71 $vars = \func_get_args();
72 unset($vars[0], $vars[1]);
73 }
74
75 $dump = fopen('php://memory', 'r+b');
76 $this->dumper = $this->dumper ?: new HtmlDumper();
77 $this->dumper->setCharset($env->getCharset());
78
79 foreach ($vars as $value) {
80 $this->dumper->dump($this->cloner->cloneVar($value), $dump);
81 }
82
83 return stream_get_contents($dump, -1, 0);
84 }
85 }
86