You are here

class PhpConfigDataCollector in Devel 8.2

Same name and namespace in other branches
  1. 8.3 webprofiler/src/DataCollector/PhpConfigDataCollector.php \Drupal\webprofiler\DataCollector\PhpConfigDataCollector
  2. 8 webprofiler/src/DataCollector/PhpConfigDataCollector.php \Drupal\webprofiler\DataCollector\PhpConfigDataCollector
  3. 4.x webprofiler/src/DataCollector/PhpConfigDataCollector.php \Drupal\webprofiler\DataCollector\PhpConfigDataCollector

Provides a data collector to collect all kind of php information.

Hierarchy

Expanded class hierarchy of PhpConfigDataCollector

1 string reference to 'PhpConfigDataCollector'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses PhpConfigDataCollector
webprofiler.php_config in webprofiler/webprofiler.services.yml
Drupal\webprofiler\DataCollector\PhpConfigDataCollector

File

webprofiler/src/DataCollector/PhpConfigDataCollector.php, line 15

Namespace

Drupal\webprofiler\DataCollector
View source
class PhpConfigDataCollector extends DataCollector implements DrupalDataCollectorInterface {
  use StringTranslationTrait, DrupalDataCollectorTrait, LinkGeneratorTrait;

  /**
   * {@inheritdoc}
   */
  public function collect(Request $request, Response $response, \Exception $exception = NULL) {
    $this->data = [
      'token' => $response->headers
        ->get('X-Debug-Token'),
      'php_version' => PHP_VERSION,
      'xdebug_enabled' => extension_loaded('xdebug'),
      'xhprof_enabled' => extension_loaded('xhprof'),
      'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'),
      'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'),
      'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'),
      'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'),
      'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'),
      'sapi_name' => php_sapi_name(),
    ];
  }

  /**
   * Gets the token.
   *
   * @return string The token
   */
  public function getToken() {
    return $this->data['token'];
  }

  /**
   * Gets the PHP version.
   *
   * @return string The PHP version
   */
  public function getPhpVersion() {
    return $this->data['php_version'];
  }

  /**
   * Returns true if the XDebug is enabled.
   *
   * @return Boolean true if XDebug is enabled, false otherwise
   */
  public function hasXDebug() {
    return $this->data['xdebug_enabled'];
  }

  /**
   * Returns true if the XHProf is enabled.
   *
   * @return Boolean true if XHProf is enabled, false otherwise
   */
  public function hasXHProf() {
    return $this->data['xhprof_enabled'];
  }

  /**
   * Returns true if EAccelerator is enabled.
   *
   * @return Boolean true if EAccelerator is enabled, false otherwise
   */
  public function hasEAccelerator() {
    return $this->data['eaccel_enabled'];
  }

  /**
   * Returns true if APC is enabled.
   *
   * @return Boolean true if APC is enabled, false otherwise
   */
  public function hasApc() {
    return $this->data['apc_enabled'];
  }

  /**
   * Returns true if Zend OPcache is enabled
   *
   * @return Boolean true if Zend OPcache is enabled, false otherwise
   */
  public function hasZendOpcache() {
    return $this->data['zend_opcache_enabled'];
  }

  /**
   * Returns true if XCache is enabled.
   *
   * @return Boolean true if XCache is enabled, false otherwise
   */
  public function hasXCache() {
    return $this->data['xcache_enabled'];
  }

  /**
   * Returns true if WinCache is enabled.
   *
   * @return Boolean true if WinCache is enabled, false otherwise
   */
  public function hasWinCache() {
    return $this->data['wincache_enabled'];
  }

  /**
   * Returns true if any accelerator is enabled.
   *
   * @return Boolean true if any accelerator is enabled, false otherwise
   */
  public function hasAccelerator() {
    return $this
      ->hasApc() || $this
      ->hasZendOpcache() || $this
      ->hasEAccelerator() || $this
      ->hasXCache() || $this
      ->hasWinCache();
  }

  /**
   * Gets the PHP SAPI name.
   *
   * @return string The environment
   */
  public function getSapiName() {
    return $this->data['sapi_name'];
  }

  /**
   * {@inheritdoc}
   */
  public function getTitle() {
    return $this
      ->t('PHP Config');
  }

  /**
   * {@inheritdoc}
   */
  public function getPanelSummary() {
    return $this
      ->t('PHP: @version', [
      '@version' => $this
        ->getPhpVersion(),
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function getName() {
    return 'php_config';
  }

  /**
   * {@inheritdoc}
   */
  public function getIcon() {
    return 'iVBORw0KGgoAAAANSUhEUgAAABUAAAAcCAMAAAC5xgRsAAAAZlBMVEX///////////////////////////////////////////////////////////////////////////////////////////+ZmZmZmZlISEhJSUmdnZ1HR0fR0dFZWVlpaWlfX18/Pz+puygPAAAAIXRSTlMACwwlJygpLzIzNjs8QEtMUmd6e32AucDBw8fIydTm6u5l8MjvAAAAo0lEQVR42r2P2Q6CMBBFL6XsZRGRfZv//0nbDBNEE19MnJeTc5ILKf58ahiUwzy/AJpIWwREwQnEXRdbGCLjrO+djWRvVMiJcigxB7viGogxDdJpSmHEmCVPS7YczJvgUu+CS30IvtbNYZMvsGVo2mVpG/kbm4auiCpdcC3YPCAhSpAdUzaAn6qPKZtUT6ZSzb4bi2hdo9MQ1nX4ASjfV+/4/Z40pyCHrNTbIgAAAABJRU5ErkJggg==';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalDataCollectorInterface::getData public function 8
DrupalDataCollectorInterface::getDrupalSettings public function 1
DrupalDataCollectorInterface::getLibraries public function Returns the libraries needed in detail panel. 2
DrupalDataCollectorInterface::hasPanel public function Returns true if this datacollector has a detail panel. 2
PhpConfigDataCollector::collect public function Collects data for the given Request and Response.
PhpConfigDataCollector::getIcon public function Returns the collector icon in base64 format. Overrides DrupalDataCollectorInterface::getIcon
PhpConfigDataCollector::getName public function Returns the name of the collector. Overrides DrupalDataCollectorInterface::getName
PhpConfigDataCollector::getPanelSummary public function Returns the string used in vertical tab summary. Overrides DrupalDataCollectorInterface::getPanelSummary
PhpConfigDataCollector::getPhpVersion public function Gets the PHP version.
PhpConfigDataCollector::getSapiName public function Gets the PHP SAPI name.
PhpConfigDataCollector::getTitle public function Returns the datacollector title. Overrides DrupalDataCollectorInterface::getTitle
PhpConfigDataCollector::getToken public function Gets the token.
PhpConfigDataCollector::hasAccelerator public function Returns true if any accelerator is enabled.
PhpConfigDataCollector::hasApc public function Returns true if APC is enabled.
PhpConfigDataCollector::hasEAccelerator public function Returns true if EAccelerator is enabled.
PhpConfigDataCollector::hasWinCache public function Returns true if WinCache is enabled.
PhpConfigDataCollector::hasXCache public function Returns true if XCache is enabled.
PhpConfigDataCollector::hasXDebug public function Returns true if the XDebug is enabled.
PhpConfigDataCollector::hasXHProf public function Returns true if the XHProf is enabled.
PhpConfigDataCollector::hasZendOpcache public function Returns true if Zend OPcache is enabled
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.