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

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

DebugHandlersListener.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 5.46 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\EventListener;
013   
014  use Psr\Log\LoggerInterface;
015  use Symfony\Component\Debug\ErrorHandler;
016  use Symfony\Component\Debug\ExceptionHandler;
017  use Symfony\Component\EventDispatcher\Event;
018  use Symfony\Component\EventDispatcher\EventSubscriberInterface;
019  use Symfony\Component\HttpKernel\Event\KernelEvent;
020  use Symfony\Component\HttpKernel\KernelEvents;
021  use Symfony\Component\Console\ConsoleEvents;
022  use Symfony\Component\Console\Event\ConsoleEvent;
023  use Symfony\Component\Console\Output\ConsoleOutputInterface;
024   
025  /**
026   * Configures errors and exceptions handlers.
027   *
028   * @author Nicolas Grekas <p@tchwork.com>
029   */
030  class DebugHandlersListener implements EventSubscriberInterface
031  {
032      private $exceptionHandler;
033      private $logger;
034      private $levels;
035      private $throwAt;
036      private $scream;
037      private $fileLinkFormat;
038      private $firstCall = true;
039   
040      /**
041       * @param callable|null        $exceptionHandler A handler that will be called on Exception
042       * @param LoggerInterface|null $logger           A PSR-3 logger
043       * @param array|int            $levels           An array map of E_* to LogLevel::* or an integer bit field of E_* constants
044       * @param int|null             $throwAt          Thrown errors in a bit field of E_* constants, or null to keep the current value
045       * @param bool                 $scream           Enables/disables screaming mode, where even silenced errors are logged
046       * @param string               $fileLinkFormat   The format for links to source files
047       */
048      public function __construct($exceptionHandler, LoggerInterface $logger = null, $levels = null, $throwAt = -1, $scream = true, $fileLinkFormat = null)
049      {
050          $this->exceptionHandler = $exceptionHandler;
051          $this->logger = $logger;
052          $this->levels = $levels;
053          $this->throwAt = is_numeric($throwAt) ? (int) $throwAt : (null === $throwAt ? null : ($throwAt ? -1 : null));
054          $this->scream = (bool) $scream;
055          $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
056      }
057   
058      /**
059       * Configures the error handler.
060       *
061       * @param Event|null $event The triggering event
062       */
063      public function configure(Event $event = null)
064      {
065          if (!$this->firstCall) {
066              return;
067          }
068          $this->firstCall = false;
069          if ($this->logger || null !== $this->throwAt) {
070              $handler = set_error_handler('var_dump');
071              $handler = is_array($handler) ? $handler[0] : null;
072              restore_error_handler();
073              if ($handler instanceof ErrorHandler) {
074                  if ($this->logger) {
075                      $handler->setDefaultLogger($this->logger, $this->levels);
076                      if (is_array($this->levels)) {
077                          $scream = 0;
078                          foreach ($this->levels as $type => $log) {
079                              $scream |= $type;
080                          }
081                      } else {
082                          $scream = null === $this->levels ? E_ALL | E_STRICT : $this->levels;
083                      }
084                      if ($this->scream) {
085                          $handler->screamAt($scream);
086                      }
087                      $this->logger = $this->levels = null;
088                  }
089                  if (null !== $this->throwAt) {
090                      $handler->throwAt($this->throwAt, true);
091                  }
092              }
093          }
094          if (!$this->exceptionHandler) {
095              if ($event instanceof KernelEvent) {
096                  if (method_exists($event->getKernel(), 'terminateWithException')) {
097                      $this->exceptionHandler = array($event->getKernel(), 'terminateWithException');
098                  }
099              } elseif ($event instanceof ConsoleEvent && $app = $event->getCommand()->getApplication()) {
100                  $output = $event->getOutput();
101                  if ($output instanceof ConsoleOutputInterface) {
102                      $output = $output->getErrorOutput();
103                  }
104                  $this->exceptionHandler = function ($e) use ($app, $output) {
105                      $app->renderException($e, $output);
106                  };
107              }
108          }
109          if ($this->exceptionHandler) {
110              $handler = set_exception_handler('var_dump');
111              $handler = is_array($handler) ? $handler[0] : null;
112              restore_exception_handler();
113              if ($handler instanceof ErrorHandler) {
114                  $h = $handler->setExceptionHandler('var_dump') ?: $this->exceptionHandler;
115                  $handler->setExceptionHandler($h);
116                  $handler = is_array($h) ? $h[0] : null;
117              }
118              if ($handler instanceof ExceptionHandler) {
119                  $handler->setHandler($this->exceptionHandler);
120                  if (null !== $this->fileLinkFormat) {
121                      $handler->setFileLinkFormat($this->fileLinkFormat);
122                  }
123              }
124              $this->exceptionHandler = null;
125          }
126      }
127   
128      public static function getSubscribedEvents()
129      {
130          $events = array(KernelEvents::REQUEST => array('configure', 2048));
131   
132          if (defined('Symfony\Component\Console\ConsoleEvents::COMMAND')) {
133              $events[ConsoleEvents::COMMAND] = array('configure', 2048);
134          }
135   
136          return $events;
137      }
138  }
139