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 |
TraceableEventDispatcher.php
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\Debug;
013
014 use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher as BaseTraceableEventDispatcher;
015 use Symfony\Component\HttpKernel\Profiler\Profiler;
016 use Symfony\Component\HttpKernel\KernelEvents;
017 use Symfony\Component\EventDispatcher\Event;
018
019 /**
020 * Collects some data about event listeners.
021 *
022 * This event dispatcher delegates the dispatching to another one.
023 *
024 * @author Fabien Potencier <fabien@symfony.com>
025 */
026 class TraceableEventDispatcher extends BaseTraceableEventDispatcher
027 {
028 /**
029 * Sets the profiler.
030 *
031 * The traceable event dispatcher does not use the profiler anymore.
032 * The job is now done directly by the Profiler listener and the
033 * data collectors themselves.
034 *
035 * @param Profiler|null $profiler A Profiler instance
036 *
037 * @deprecated since version 2.4, to be removed in 3.0.
038 */
039 public function setProfiler(Profiler $profiler = null)
040 {
041 @trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0.', E_USER_DEPRECATED);
042 }
043
044 /**
045 * {@inheritdoc}
046 */
047 protected function preDispatch($eventName, Event $event)
048 {
049 switch ($eventName) {
050 case KernelEvents::REQUEST:
051 $this->stopwatch->openSection();
052 break;
053 case KernelEvents::VIEW:
054 case KernelEvents::RESPONSE:
055 // stop only if a controller has been executed
056 if ($this->stopwatch->isStarted('controller')) {
057 $this->stopwatch->stop('controller');
058 }
059 break;
060 case KernelEvents::TERMINATE:
061 $token = $event->getResponse()->headers->get('X-Debug-Token');
062 // There is a very special case when using built-in AppCache class as kernel wrapper, in the case
063 // of an ESI request leading to a `stale` response [B] inside a `fresh` cached response [A].
064 // In this case, `$token` contains the [B] debug token, but the open `stopwatch` section ID
065 // is equal to the [A] debug token. Trying to reopen section with the [B] token throws an exception
066 // which must be caught.
067 try {
068 $this->stopwatch->openSection($token);
069 } catch (\LogicException $e) {
070 }
071 break;
072 }
073 }
074
075 /**
076 * {@inheritdoc}
077 */
078 protected function postDispatch($eventName, Event $event)
079 {
080 switch ($eventName) {
081 case KernelEvents::CONTROLLER:
082 $this->stopwatch->start('controller', 'section');
083 break;
084 case KernelEvents::RESPONSE:
085 $token = $event->getResponse()->headers->get('X-Debug-Token');
086 $this->stopwatch->stopSection($token);
087 break;
088 case KernelEvents::TERMINATE:
089 // In the special case described in the `preDispatch` method above, the `$token` section
090 // does not exist, then closing it throws an exception which must be caught.
091 $token = $event->getResponse()->headers->get('X-Debug-Token');
092 try {
093 $this->stopwatch->stopSection($token);
094 } catch (\LogicException $e) {
095 }
096 break;
097 }
098 }
099 }
100