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

InlineFragmentRenderer.php

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


001  <?php
002   
003  /*
004   * This file is part of the Symfony package.
005   *
006   * (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\HttpKernel\Fragment;
013   
014  use Symfony\Component\EventDispatcher\EventDispatcherInterface;
015  use Symfony\Component\HttpFoundation\Request;
016  use Symfony\Component\HttpFoundation\Response;
017  use Symfony\Component\HttpKernel\Controller\ControllerReference;
018  use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
019  use Symfony\Component\HttpKernel\HttpCache\SubRequestHandler;
020  use Symfony\Component\HttpKernel\HttpKernelInterface;
021  use Symfony\Component\HttpKernel\KernelEvents;
022   
023  /**
024   * Implements the inline rendering strategy where the Request is rendered by the current HTTP kernel.
025   *
026   * @author Fabien Potencier <fabien@symfony.com>
027   */
028  class InlineFragmentRenderer extends RoutableFragmentRenderer
029  {
030      private $kernel;
031      private $dispatcher;
032   
033      public function __construct(HttpKernelInterface $kernel, EventDispatcherInterface $dispatcher = null)
034      {
035          $this->kernel = $kernel;
036          $this->dispatcher = $dispatcher;
037      }
038   
039      /**
040       * {@inheritdoc}
041       *
042       * Additional available options:
043       *
044       *  * alt: an alternative URI to render in case of an error
045       */
046      public function render($uri, Request $request, array $options = [])
047      {
048          $reference = null;
049          if ($uri instanceof ControllerReference) {
050              $reference = $uri;
051   
052              // Remove attributes from the generated URI because if not, the Symfony
053              // routing system will use them to populate the Request attributes. We don't
054              // want that as we want to preserve objects (so we manually set Request attributes
055              // below instead)
056              $attributes = $reference->attributes;
057              $reference->attributes = [];
058   
059              // The request format and locale might have been overridden by the user
060              foreach (['_format', '_locale'] as $key) {
061                  if (isset($attributes[$key])) {
062                      $reference->attributes[$key] = $attributes[$key];
063                  }
064              }
065   
066              $uri = $this->generateFragmentUri($uri, $request, false, false);
067   
068              $reference->attributes = array_merge($attributes, $reference->attributes);
069          }
070   
071          $subRequest = $this->createSubRequest($uri, $request);
072   
073          // override Request attributes as they can be objects (which are not supported by the generated URI)
074          if (null !== $reference) {
075              $subRequest->attributes->add($reference->attributes);
076          }
077   
078          $level = ob_get_level();
079          try {
080              return SubRequestHandler::handle($this->kernel, $subRequest, HttpKernelInterface::SUB_REQUEST, false);
081          } catch (\Exception $e) {
082              // we dispatch the exception event to trigger the logging
083              // the response that comes back is ignored
084              if (isset($options['ignore_errors']) && $options['ignore_errors'] && $this->dispatcher) {
085                  $event = new GetResponseForExceptionEvent($this->kernel, $request, HttpKernelInterface::SUB_REQUEST, $e);
086   
087                  $this->dispatcher->dispatch(KernelEvents::EXCEPTION, $event);
088              }
089   
090              // let's clean up the output buffers that were created by the sub-request
091              Response::closeOutputBuffers($level, false);
092   
093              if (isset($options['alt'])) {
094                  $alt = $options['alt'];
095                  unset($options['alt']);
096   
097                  return $this->render($alt, $request, $options);
098              }
099   
100              if (!isset($options['ignore_errors']) || !$options['ignore_errors']) {
101                  throw $e;
102              }
103   
104              return new Response();
105          }
106      }
107   
108      protected function createSubRequest($uri, Request $request)
109      {
110          $cookies = $request->cookies->all();
111          $server = $request->server->all();
112   
113          unset($server['HTTP_IF_MODIFIED_SINCE']);
114          unset($server['HTTP_IF_NONE_MATCH']);
115   
116          $subRequest = Request::create($uri, 'get', [], $cookies, [], $server);
117          if ($request->headers->has('Surrogate-Capability')) {
118              $subRequest->headers->set('Surrogate-Capability', $request->headers->get('Surrogate-Capability'));
119          }
120   
121          if ($session = $request->getSession()) {
122              $subRequest->setSession($session);
123          }
124   
125          if ($request->get('_format')) {
126              $subRequest->attributes->set('_format', $request->get('_format'));
127          }
128          if ($request->getDefaultLocale() !== $request->getLocale()) {
129              $subRequest->setLocale($request->getLocale());
130          }
131   
132          return $subRequest;
133      }
134   
135      /**
136       * {@inheritdoc}
137       */
138      public function getName()
139      {
140          return 'inline';
141      }
142  }
143