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

ConfigDataCollector.php

Zuletzt modifiziert: 02.04.2025, 15:03 - Dateigröße: 8.55 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\Kernel;
017  use Symfony\Component\HttpKernel\KernelInterface;
018  use Symfony\Component\VarDumper\Caster\LinkStub;
019   
020  /**
021   * @author Fabien Potencier <fabien@symfony.com>
022   */
023  class ConfigDataCollector extends DataCollector implements LateDataCollectorInterface
024  {
025      /**
026       * @var KernelInterface
027       */
028      private $kernel;
029      private $name;
030      private $version;
031      private $hasVarDumper;
032   
033      /**
034       * @param string $name    The name of the application using the web profiler
035       * @param string $version The version of the application using the web profiler
036       */
037      public function __construct($name = null, $version = null)
038      {
039          $this->name = $name;
040          $this->version = $version;
041          $this->hasVarDumper = class_exists(LinkStub::class);
042      }
043   
044      /**
045       * Sets the Kernel associated with this Request.
046       */
047      public function setKernel(KernelInterface $kernel = null)
048      {
049          $this->kernel = $kernel;
050      }
051   
052      /**
053       * {@inheritdoc}
054       */
055      public function collect(Request $request, Response $response, \Exception $exception = null)
056      {
057          $this->data = [
058              'app_name' => $this->name,
059              'app_version' => $this->version,
060              'token' => $response->headers->get('X-Debug-Token'),
061              'symfony_version' => Kernel::VERSION,
062              'symfony_state' => 'unknown',
063              'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
064              'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
065              'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
066              'php_version' => \PHP_VERSION,
067              'php_architecture' => \PHP_INT_SIZE * 8,
068              'php_intl_locale' => class_exists('Locale', false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a',
069              'php_timezone' => date_default_timezone_get(),
070              'xdebug_enabled' => \extension_loaded('xdebug'),
071              'apcu_enabled' => \extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN),
072              'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN),
073              'bundles' => [],
074              'sapi_name' => \PHP_SAPI,
075          ];
076   
077          if (isset($this->kernel)) {
078              foreach ($this->kernel->getBundles() as $name => $bundle) {
079                  $this->data['bundles'][$name] = $this->hasVarDumper ? new LinkStub($bundle->getPath()) : $bundle->getPath();
080              }
081   
082              $this->data['symfony_state'] = $this->determineSymfonyState();
083              $this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION);
084              $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE);
085              $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE);
086              $this->data['symfony_eom'] = $eom->format('F Y');
087              $this->data['symfony_eol'] = $eol->format('F Y');
088          }
089   
090          if (preg_match('~^(\d+(?:\.\d+)*)(.+)?$~', $this->data['php_version'], $matches) && isset($matches[2])) {
091              $this->data['php_version'] = $matches[1];
092              $this->data['php_version_extra'] = $matches[2];
093          }
094      }
095   
096      /**
097       * {@inheritdoc}
098       */
099      public function reset()
100      {
101          $this->data = [];
102      }
103   
104      public function lateCollect()
105      {
106          $this->data = $this->cloneVar($this->data);
107      }
108   
109      public function getApplicationName()
110      {
111          return $this->data['app_name'];
112      }
113   
114      public function getApplicationVersion()
115      {
116          return $this->data['app_version'];
117      }
118   
119      /**
120       * Gets the token.
121       *
122       * @return string|null The token
123       */
124      public function getToken()
125      {
126          return $this->data['token'];
127      }
128   
129      /**
130       * Gets the Symfony version.
131       *
132       * @return string The Symfony version
133       */
134      public function getSymfonyVersion()
135      {
136          return $this->data['symfony_version'];
137      }
138   
139      /**
140       * Returns the state of the current Symfony release.
141       *
142       * @return string One of: unknown, dev, stable, eom, eol
143       */
144      public function getSymfonyState()
145      {
146          return $this->data['symfony_state'];
147      }
148   
149      /**
150       * Returns the minor Symfony version used (without patch numbers of extra
151       * suffix like "RC", "beta", etc.).
152       *
153       * @return string
154       */
155      public function getSymfonyMinorVersion()
156      {
157          return $this->data['symfony_minor_version'];
158      }
159   
160      /**
161       * Returns the human redable date when this Symfony version ends its
162       * maintenance period.
163       *
164       * @return string
165       */
166      public function getSymfonyEom()
167      {
168          return $this->data['symfony_eom'];
169      }
170   
171      /**
172       * Returns the human redable date when this Symfony version reaches its
173       * "end of life" and won't receive bugs or security fixes.
174       *
175       * @return string
176       */
177      public function getSymfonyEol()
178      {
179          return $this->data['symfony_eol'];
180      }
181   
182      /**
183       * Gets the PHP version.
184       *
185       * @return string The PHP version
186       */
187      public function getPhpVersion()
188      {
189          return $this->data['php_version'];
190      }
191   
192      /**
193       * Gets the PHP version extra part.
194       *
195       * @return string|null The extra part
196       */
197      public function getPhpVersionExtra()
198      {
199          return isset($this->data['php_version_extra']) ? $this->data['php_version_extra'] : null;
200      }
201   
202      /**
203       * @return int The PHP architecture as number of bits (e.g. 32 or 64)
204       */
205      public function getPhpArchitecture()
206      {
207          return $this->data['php_architecture'];
208      }
209   
210      /**
211       * @return string
212       */
213      public function getPhpIntlLocale()
214      {
215          return $this->data['php_intl_locale'];
216      }
217   
218      /**
219       * @return string
220       */
221      public function getPhpTimezone()
222      {
223          return $this->data['php_timezone'];
224      }
225   
226      /**
227       * Gets the application name.
228       *
229       * @return string The application name
230       */
231      public function getAppName()
232      {
233          return $this->data['name'];
234      }
235   
236      /**
237       * Gets the environment.
238       *
239       * @return string The environment
240       */
241      public function getEnv()
242      {
243          return $this->data['env'];
244      }
245   
246      /**
247       * Returns true if the debug is enabled.
248       *
249       * @return bool true if debug is enabled, false otherwise
250       */
251      public function isDebug()
252      {
253          return $this->data['debug'];
254      }
255   
256      /**
257       * Returns true if the XDebug is enabled.
258       *
259       * @return bool true if XDebug is enabled, false otherwise
260       */
261      public function hasXDebug()
262      {
263          return $this->data['xdebug_enabled'];
264      }
265   
266      /**
267       * Returns true if APCu is enabled.
268       *
269       * @return bool true if APCu is enabled, false otherwise
270       */
271      public function hasApcu()
272      {
273          return $this->data['apcu_enabled'];
274      }
275   
276      /**
277       * Returns true if Zend OPcache is enabled.
278       *
279       * @return bool true if Zend OPcache is enabled, false otherwise
280       */
281      public function hasZendOpcache()
282      {
283          return $this->data['zend_opcache_enabled'];
284      }
285   
286      public function getBundles()
287      {
288          return $this->data['bundles'];
289      }
290   
291      /**
292       * Gets the PHP SAPI name.
293       *
294       * @return string The environment
295       */
296      public function getSapiName()
297      {
298          return $this->data['sapi_name'];
299      }
300   
301      /**
302       * {@inheritdoc}
303       */
304      public function getName()
305      {
306          return 'config';
307      }
308   
309      /**
310       * Tries to retrieve information about the current Symfony version.
311       *
312       * @return string One of: dev, stable, eom, eol
313       */
314      private function determineSymfonyState()
315      {
316          $now = new \DateTime();
317          $eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->modify('last day of this month');
318          $eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE)->modify('last day of this month');
319   
320          if ($now > $eol) {
321              $versionState = 'eol';
322          } elseif ($now > $eom) {
323              $versionState = 'eom';
324          } elseif ('' !== Kernel::EXTRA_VERSION) {
325              $versionState = 'dev';
326          } else {
327              $versionState = 'stable';
328          }
329   
330          return $versionState;
331      }
332  }
333