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

TimeDataCollector.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 3.14 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\DataCollector;
013   
014  use Symfony\Component\HttpFoundation\Request;
015  use Symfony\Component\HttpFoundation\Response;
016  use Symfony\Component\HttpKernel\KernelInterface;
017   
018  /**
019   * TimeDataCollector.
020   *
021   * @author Fabien Potencier <fabien@symfony.com>
022   */
023  class TimeDataCollector extends DataCollector implements LateDataCollectorInterface
024  {
025      protected $kernel;
026      protected $stopwatch;
027   
028      public function __construct(KernelInterface $kernel = null, $stopwatch = null)
029      {
030          $this->kernel = $kernel;
031          $this->stopwatch = $stopwatch;
032      }
033   
034      /**
035       * {@inheritdoc}
036       */
037      public function collect(Request $request, Response $response, \Exception $exception = null)
038      {
039          if (null !== $this->kernel) {
040              $startTime = $this->kernel->getStartTime();
041          } else {
042              $startTime = $request->server->get('REQUEST_TIME_FLOAT', $request->server->get('REQUEST_TIME'));
043          }
044   
045          $this->data = array(
046              'token' => $response->headers->get('X-Debug-Token'),
047              'start_time' => $startTime * 1000,
048              'events' => array(),
049          );
050      }
051   
052      /**
053       * {@inheritdoc}
054       */
055      public function lateCollect()
056      {
057          if (null !== $this->stopwatch && isset($this->data['token'])) {
058              $this->setEvents($this->stopwatch->getSectionEvents($this->data['token']));
059          }
060          unset($this->data['token']);
061      }
062   
063      /**
064       * Sets the request events.
065       *
066       * @param array $events The request events
067       */
068      public function setEvents(array $events)
069      {
070          foreach ($events as $event) {
071              $event->ensureStopped();
072          }
073   
074          $this->data['events'] = $events;
075      }
076   
077      /**
078       * Gets the request events.
079       *
080       * @return array The request events
081       */
082      public function getEvents()
083      {
084          return $this->data['events'];
085      }
086   
087      /**
088       * Gets the request elapsed time.
089       *
090       * @return float The elapsed time
091       */
092      public function getDuration()
093      {
094          if (!isset($this->data['events']['__section__'])) {
095              return 0;
096          }
097   
098          $lastEvent = $this->data['events']['__section__'];
099   
100          return $lastEvent->getOrigin() + $lastEvent->getDuration() - $this->getStartTime();
101      }
102   
103      /**
104       * Gets the initialization time.
105       *
106       * This is the time spent until the beginning of the request handling.
107       *
108       * @return float The elapsed time
109       */
110      public function getInitTime()
111      {
112          if (!isset($this->data['events']['__section__'])) {
113              return 0;
114          }
115   
116          return $this->data['events']['__section__']->getOrigin() - $this->getStartTime();
117      }
118   
119      /**
120       * Gets the request time.
121       *
122       * @return int The time
123       */
124      public function getStartTime()
125      {
126          return $this->data['start_time'];
127      }
128   
129      /**
130       * {@inheritdoc}
131       */
132      public function getName()
133      {
134          return 'time';
135      }
136  }
137