[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/vendor/symfony/http-kernel/DataCollector/ -> ConfigDataCollector.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the Symfony package.
   5   *
   6   * (c) Fabien Potencier <fabien@symfony.com>
   7   *
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  namespace Symfony\Component\HttpKernel\DataCollector;
  13  
  14  use Symfony\Component\HttpFoundation\Request;
  15  use Symfony\Component\HttpFoundation\Response;
  16  use Symfony\Component\HttpKernel\Kernel;
  17  use Symfony\Component\HttpKernel\KernelInterface;
  18  
  19  /**
  20   * @author Fabien Potencier <fabien@symfony.com>
  21   */
  22  class ConfigDataCollector extends DataCollector
  23  {
  24      /**
  25       * @var KernelInterface
  26       */
  27      private $kernel;
  28      private $name;
  29      private $version;
  30  
  31      /**
  32       * @param string $name    The name of the application using the web profiler
  33       * @param string $version The version of the application using the web profiler
  34       */
  35      public function __construct($name = null, $version = null)
  36      {
  37          $this->name = $name;
  38          $this->version = $version;
  39      }
  40  
  41      /**
  42       * Sets the Kernel associated with this Request.
  43       */
  44      public function setKernel(KernelInterface $kernel = null)
  45      {
  46          $this->kernel = $kernel;
  47      }
  48  
  49      /**
  50       * {@inheritdoc}
  51       */
  52      public function collect(Request $request, Response $response, \Exception $exception = null)
  53      {
  54          $this->data = array(
  55              'app_name' => $this->name,
  56              'app_version' => $this->version,
  57              'token' => $response->headers->get('X-Debug-Token'),
  58              'symfony_version' => Kernel::VERSION,
  59              'symfony_state' => 'unknown',
  60              'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
  61              'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
  62              'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
  63              'php_version' => PHP_VERSION,
  64              'xdebug_enabled' => \extension_loaded('xdebug'),
  65              'eaccel_enabled' => \extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'),
  66              'apc_enabled' => \extension_loaded('apc') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN),
  67              'xcache_enabled' => \extension_loaded('xcache') && filter_var(ini_get('xcache.cacher'), FILTER_VALIDATE_BOOLEAN),
  68              'wincache_enabled' => \extension_loaded('wincache') && filter_var(ini_get('wincache.ocenabled'), FILTER_VALIDATE_BOOLEAN),
  69              'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN),
  70              'bundles' => array(),
  71              'sapi_name' => \PHP_SAPI,
  72          );
  73  
  74          if (isset($this->kernel)) {
  75              foreach ($this->kernel->getBundles() as $name => $bundle) {
  76                  $this->data['bundles'][$name] = $bundle->getPath();
  77              }
  78  
  79              $this->data['symfony_state'] = $this->determineSymfonyState();
  80          }
  81      }
  82  
  83      public function getApplicationName()
  84      {
  85          return $this->data['app_name'];
  86      }
  87  
  88      public function getApplicationVersion()
  89      {
  90          return $this->data['app_version'];
  91      }
  92  
  93      /**
  94       * Gets the token.
  95       *
  96       * @return string The token
  97       */
  98      public function getToken()
  99      {
 100          return $this->data['token'];
 101      }
 102  
 103      /**
 104       * Gets the Symfony version.
 105       *
 106       * @return string The Symfony version
 107       */
 108      public function getSymfonyVersion()
 109      {
 110          return $this->data['symfony_version'];
 111      }
 112  
 113      /**
 114       * Returns the state of the current Symfony release.
 115       *
 116       * @return string One of: unknown, dev, stable, eom, eol
 117       */
 118      public function getSymfonyState()
 119      {
 120          return $this->data['symfony_state'];
 121      }
 122  
 123      public function setCacheVersionInfo($cacheVersionInfo)
 124      {
 125          // no-op for BC
 126      }
 127  
 128      /**
 129       * Gets the PHP version.
 130       *
 131       * @return string The PHP version
 132       */
 133      public function getPhpVersion()
 134      {
 135          return $this->data['php_version'];
 136      }
 137  
 138      /**
 139       * Gets the application name.
 140       *
 141       * @return string The application name
 142       */
 143      public function getAppName()
 144      {
 145          return $this->data['name'];
 146      }
 147  
 148      /**
 149       * Gets the environment.
 150       *
 151       * @return string The environment
 152       */
 153      public function getEnv()
 154      {
 155          return $this->data['env'];
 156      }
 157  
 158      /**
 159       * Returns true if the debug is enabled.
 160       *
 161       * @return bool true if debug is enabled, false otherwise
 162       */
 163      public function isDebug()
 164      {
 165          return $this->data['debug'];
 166      }
 167  
 168      /**
 169       * Returns true if the XDebug is enabled.
 170       *
 171       * @return bool true if XDebug is enabled, false otherwise
 172       */
 173      public function hasXDebug()
 174      {
 175          return $this->data['xdebug_enabled'];
 176      }
 177  
 178      /**
 179       * Returns true if EAccelerator is enabled.
 180       *
 181       * @return bool true if EAccelerator is enabled, false otherwise
 182       */
 183      public function hasEAccelerator()
 184      {
 185          return $this->data['eaccel_enabled'];
 186      }
 187  
 188      /**
 189       * Returns true if APC is enabled.
 190       *
 191       * @return bool true if APC is enabled, false otherwise
 192       */
 193      public function hasApc()
 194      {
 195          return $this->data['apc_enabled'];
 196      }
 197  
 198      /**
 199       * Returns true if Zend OPcache is enabled.
 200       *
 201       * @return bool true if Zend OPcache is enabled, false otherwise
 202       */
 203      public function hasZendOpcache()
 204      {
 205          return $this->data['zend_opcache_enabled'];
 206      }
 207  
 208      /**
 209       * Returns true if XCache is enabled.
 210       *
 211       * @return bool true if XCache is enabled, false otherwise
 212       */
 213      public function hasXCache()
 214      {
 215          return $this->data['xcache_enabled'];
 216      }
 217  
 218      /**
 219       * Returns true if WinCache is enabled.
 220       *
 221       * @return bool true if WinCache is enabled, false otherwise
 222       */
 223      public function hasWinCache()
 224      {
 225          return $this->data['wincache_enabled'];
 226      }
 227  
 228      /**
 229       * Returns true if any accelerator is enabled.
 230       *
 231       * @return bool true if any accelerator is enabled, false otherwise
 232       */
 233      public function hasAccelerator()
 234      {
 235          return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache();
 236      }
 237  
 238      public function getBundles()
 239      {
 240          return $this->data['bundles'];
 241      }
 242  
 243      /**
 244       * Gets the PHP SAPI name.
 245       *
 246       * @return string The environment
 247       */
 248      public function getSapiName()
 249      {
 250          return $this->data['sapi_name'];
 251      }
 252  
 253      /**
 254       * {@inheritdoc}
 255       */
 256      public function getName()
 257      {
 258          return 'config';
 259      }
 260  
 261      /**
 262       * Tries to retrieve information about the current Symfony version.
 263       *
 264       * @return string One of: dev, stable, eom, eol
 265       */
 266      private function determineSymfonyState()
 267      {
 268          $now = new \DateTime();
 269          $eom = \DateTime::createFromFormat('m/Y', Kernel::END_OF_MAINTENANCE)->modify('last day of this month');
 270          $eol = \DateTime::createFromFormat('m/Y', Kernel::END_OF_LIFE)->modify('last day of this month');
 271  
 272          if ($now > $eol) {
 273              $versionState = 'eol';
 274          } elseif ($now > $eom) {
 275              $versionState = 'eom';
 276          } elseif ('' !== Kernel::EXTRA_VERSION) {
 277              $versionState = 'dev';
 278          } else {
 279              $versionState = 'stable';
 280          }
 281  
 282          return $versionState;
 283      }
 284  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1