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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

TemplateWrapper.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 3.67 KiB


001  <?php
002   
003  /*
004   * This file is part of Twig.
005   *
006   * (c) Fabien Potencier
007   *
008   * For the full copyright and license information, please view the LICENSE
009   * file that was distributed with this source code.
010   */
011   
012  namespace Twig;
013   
014  /**
015   * Exposes a template to userland.
016   *
017   * @author Fabien Potencier <fabien@symfony.com>
018   */
019  final class TemplateWrapper
020  {
021      private $env;
022      private $template;
023   
024      /**
025       * This method is for internal use only and should never be called
026       * directly (use Twig\Environment::load() instead).
027       *
028       * @internal
029       */
030      public function __construct(Environment $env, Template $template)
031      {
032          $this->env = $env;
033          $this->template = $template;
034      }
035   
036      /**
037       * Renders the template.
038       *
039       * @param array $context An array of parameters to pass to the template
040       */
041      public function render(array $context = []): string
042      {
043          // using func_get_args() allows to not expose the blocks argument
044          // as it should only be used by internal code
045          return $this->template->render($context, \func_get_args()[1] ?? []);
046      }
047   
048      /**
049       * Displays the template.
050       *
051       * @param array $context An array of parameters to pass to the template
052       */
053      public function display(array $context = [])
054      {
055          // using func_get_args() allows to not expose the blocks argument
056          // as it should only be used by internal code
057          $this->template->display($context, \func_get_args()[1] ?? []);
058      }
059   
060      /**
061       * Checks if a block is defined.
062       *
063       * @param string $name    The block name
064       * @param array  $context An array of parameters to pass to the template
065       */
066      public function hasBlock(string $name, array $context = []): bool
067      {
068          return $this->template->hasBlock($name, $context);
069      }
070   
071      /**
072       * Returns defined block names in the template.
073       *
074       * @param array $context An array of parameters to pass to the template
075       *
076       * @return string[] An array of defined template block names
077       */
078      public function getBlockNames(array $context = []): array
079      {
080          return $this->template->getBlockNames($context);
081      }
082   
083      /**
084       * Renders a template block.
085       *
086       * @param string $name    The block name to render
087       * @param array  $context An array of parameters to pass to the template
088       *
089       * @return string The rendered block
090       */
091      public function renderBlock(string $name, array $context = []): string
092      {
093          $context = $this->env->mergeGlobals($context);
094          $level = ob_get_level();
095          if ($this->env->isDebug()) {
096              ob_start();
097          } else {
098              ob_start(function () { return ''; });
099          }
100          try {
101              $this->template->displayBlock($name, $context);
102          } catch (\Throwable $e) {
103              while (ob_get_level() > $level) {
104                  ob_end_clean();
105              }
106   
107              throw $e;
108          }
109   
110          return ob_get_clean();
111      }
112   
113      /**
114       * Displays a template block.
115       *
116       * @param string $name    The block name to render
117       * @param array  $context An array of parameters to pass to the template
118       */
119      public function displayBlock(string $name, array $context = [])
120      {
121          $this->template->displayBlock($name, $this->env->mergeGlobals($context));
122      }
123   
124      public function getSourceContext(): Source
125      {
126          return $this->template->getSourceContext();
127      }
128   
129      public function getTemplateName(): string
130      {
131          return $this->template->getTemplateName();
132      }
133   
134      /**
135       * @internal
136       *
137       * @return Template
138       */
139      public function unwrap()
140      {
141          return $this->template;
142      }
143  }
144   
145  class_alias('Twig\TemplateWrapper', 'Twig_TemplateWrapper');
146