Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ConfigDataCollector.php

class ConfigDataCollector

@author Fabien Potencier <fabien@symfony.com>

@final

Hierarchy

  • class \Symfony\Component\HttpKernel\DataCollector\DataCollector implements \Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface
    • class \Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector extends \Symfony\Component\HttpKernel\DataCollector\DataCollector implements \Symfony\Component\HttpKernel\DataCollector\LateDataCollectorInterface

Expanded class hierarchy of ConfigDataCollector

File

vendor/symfony/http-kernel/DataCollector/ConfigDataCollector.php, line 26

Namespace

Symfony\Component\HttpKernel\DataCollector
View source
class ConfigDataCollector extends DataCollector implements LateDataCollectorInterface {
    private KernelInterface $kernel;
    
    /**
     * Sets the Kernel associated with this Request.
     */
    public function setKernel(KernelInterface $kernel) : void {
        $this->kernel = $kernel;
    }
    public function collect(Request $request, Response $response, ?\Throwable $exception = null) : void {
        $eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/' . Kernel::END_OF_MAINTENANCE);
        $eol = \DateTimeImmutable::createFromFormat('d/m/Y', '01/' . Kernel::END_OF_LIFE);
        $xdebugMode = getenv('XDEBUG_MODE') ?: \ini_get('xdebug.mode');
        $this->data = [
            'token' => $response->headers
                ->get('X-Debug-Token'),
            'symfony_version' => Kernel::VERSION,
            'symfony_minor_version' => \sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION),
            'symfony_lts' => 4 === Kernel::MINOR_VERSION,
            'symfony_state' => $this->determineSymfonyState(),
            'symfony_eom' => $eom->format('F Y'),
            'symfony_eol' => $eol->format('F Y'),
            'env' => isset($this->kernel) ? $this->kernel
                ->getEnvironment() : 'n/a',
            'debug' => isset($this->kernel) ? $this->kernel
                ->isDebug() : 'n/a',
            'php_version' => \PHP_VERSION,
            'php_architecture' => \PHP_INT_SIZE * 8,
            'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a',
            'php_timezone' => date_default_timezone_get(),
            'xdebug_enabled' => \extension_loaded('xdebug'),
            'xdebug_status' => \extension_loaded('xdebug') ? $xdebugMode && $xdebugMode !== 'off' ? 'Enabled (' . $xdebugMode . ')' : 'Not enabled' : 'Not installed',
            'apcu_enabled' => \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL),
            'apcu_status' => \extension_loaded('apcu') ? filter_var(\ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled' : 'Not installed',
            'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL),
            'zend_opcache_status' => \extension_loaded('Zend OPcache') ? filter_var(\ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled' : 'Not installed',
            'bundles' => [],
            'sapi_name' => \PHP_SAPI,
        ];
        if (isset($this->kernel)) {
            foreach ($this->kernel
                ->getBundles() as $name => $bundle) {
                $this->data['bundles'][$name] = new ClassStub($bundle::class);
            }
        }
        if (preg_match('~^(\\d+(?:\\.\\d+)*)(.+)?$~', $this->data['php_version'], $matches) && isset($matches[2])) {
            $this->data['php_version'] = $matches[1];
            $this->data['php_version_extra'] = $matches[2];
        }
    }
    public function lateCollect() : void {
        $this->data = $this->cloneVar($this->data);
    }
    
    /**
     * Gets the token.
     */
    public function getToken() : ?string {
        return $this->data['token'];
    }
    
    /**
     * Gets the Symfony version.
     */
    public function getSymfonyVersion() : string {
        return $this->data['symfony_version'];
    }
    
    /**
     * Returns the state of the current Symfony release
     * as one of: unknown, dev, stable, eom, eol.
     */
    public function getSymfonyState() : string {
        return $this->data['symfony_state'];
    }
    
    /**
     * Returns the minor Symfony version used (without patch numbers of extra
     * suffix like "RC", "beta", etc.).
     */
    public function getSymfonyMinorVersion() : string {
        return $this->data['symfony_minor_version'];
    }
    public function isSymfonyLts() : bool {
        return $this->data['symfony_lts'];
    }
    
    /**
     * Returns the human readable date when this Symfony version ends its
     * maintenance period.
     */
    public function getSymfonyEom() : string {
        return $this->data['symfony_eom'];
    }
    
    /**
     * Returns the human readable date when this Symfony version reaches its
     * "end of life" and won't receive bugs or security fixes.
     */
    public function getSymfonyEol() : string {
        return $this->data['symfony_eol'];
    }
    
    /**
     * Gets the PHP version.
     */
    public function getPhpVersion() : string {
        return $this->data['php_version'];
    }
    
    /**
     * Gets the PHP version extra part.
     */
    public function getPhpVersionExtra() : ?string {
        return $this->data['php_version_extra'] ?? null;
    }
    public function getPhpArchitecture() : int {
        return $this->data['php_architecture'];
    }
    public function getPhpIntlLocale() : string {
        return $this->data['php_intl_locale'];
    }
    public function getPhpTimezone() : string {
        return $this->data['php_timezone'];
    }
    
    /**
     * Gets the environment.
     */
    public function getEnv() : string {
        return $this->data['env'];
    }
    
    /**
     * Returns true if the debug is enabled.
     *
     * @return bool|string true if debug is enabled, false otherwise or a string if no kernel was set
     */
    public function isDebug() : bool|string {
        return $this->data['debug'];
    }
    
    /**
     * Returns true if the Xdebug is enabled.
     */
    public function hasXdebug() : bool {
        return $this->data['xdebug_enabled'];
    }
    public function getXdebugStatus() : string {
        return $this->data['xdebug_status'];
    }
    
    /**
     * Returns true if the function xdebug_info is available.
     */
    public function hasXdebugInfo() : bool {
        return \function_exists('xdebug_info');
    }
    
    /**
     * Returns true if APCu is enabled.
     */
    public function hasApcu() : bool {
        return $this->data['apcu_enabled'];
    }
    public function getApcuStatus() : string {
        return $this->data['apcu_status'];
    }
    
    /**
     * Returns true if Zend OPcache is enabled.
     */
    public function hasZendOpcache() : bool {
        return $this->data['zend_opcache_enabled'];
    }
    public function getZendOpcacheStatus() : string {
        return $this->data['zend_opcache_status'];
    }
    public function getBundles() : array|Data {
        return $this->data['bundles'];
    }
    
    /**
     * Gets the PHP SAPI name.
     */
    public function getSapiName() : string {
        return $this->data['sapi_name'];
    }
    public function getName() : string {
        return 'config';
    }
    private function determineSymfonyState() : string {
        $now = new \DateTimeImmutable();
        $eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/' . Kernel::END_OF_MAINTENANCE)->modify('last day of this month');
        $eol = \DateTimeImmutable::createFromFormat('d/m/Y', '01/' . Kernel::END_OF_LIFE)->modify('last day of this month');
        if ($now > $eol) {
            $versionState = 'eol';
        }
        elseif ($now > $eom) {
            $versionState = 'eom';
        }
        elseif ('' !== Kernel::EXTRA_VERSION) {
            $versionState = 'dev';
        }
        else {
            $versionState = 'stable';
        }
        return $versionState;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
ConfigDataCollector::$kernel private property
ConfigDataCollector::collect public function Collects data for the given Request and Response. Overrides DataCollectorInterface::collect
ConfigDataCollector::determineSymfonyState private function
ConfigDataCollector::getApcuStatus public function
ConfigDataCollector::getBundles public function
ConfigDataCollector::getEnv public function Gets the environment.
ConfigDataCollector::getName public function Returns the name of the collector. Overrides DataCollectorInterface::getName
ConfigDataCollector::getPhpArchitecture public function
ConfigDataCollector::getPhpIntlLocale public function
ConfigDataCollector::getPhpTimezone public function
ConfigDataCollector::getPhpVersion public function Gets the PHP version.
ConfigDataCollector::getPhpVersionExtra public function Gets the PHP version extra part.
ConfigDataCollector::getSapiName public function Gets the PHP SAPI name.
ConfigDataCollector::getSymfonyEol public function Returns the human readable date when this Symfony version reaches its
&quot;end of life&quot; and won&#039;t receive bugs or security fixes.
ConfigDataCollector::getSymfonyEom public function Returns the human readable date when this Symfony version ends its
maintenance period.
ConfigDataCollector::getSymfonyMinorVersion public function Returns the minor Symfony version used (without patch numbers of extra
suffix like &quot;RC&quot;, &quot;beta&quot;, etc.).
ConfigDataCollector::getSymfonyState public function Returns the state of the current Symfony release
as one of: unknown, dev, stable, eom, eol.
ConfigDataCollector::getSymfonyVersion public function Gets the Symfony version.
ConfigDataCollector::getToken public function Gets the token.
ConfigDataCollector::getXdebugStatus public function
ConfigDataCollector::getZendOpcacheStatus public function
ConfigDataCollector::hasApcu public function Returns true if APCu is enabled.
ConfigDataCollector::hasXdebug public function Returns true if the Xdebug is enabled.
ConfigDataCollector::hasXdebugInfo public function Returns true if the function xdebug_info is available.
ConfigDataCollector::hasZendOpcache public function Returns true if Zend OPcache is enabled.
ConfigDataCollector::isDebug public function Returns true if the debug is enabled.
ConfigDataCollector::isSymfonyLts public function
ConfigDataCollector::lateCollect public function Collects data as late as possible. Overrides LateDataCollectorInterface::lateCollect
ConfigDataCollector::setKernel public function Sets the Kernel associated with this Request.
DataCollector::$cloner private property
DataCollector::$data protected property
DataCollector::cloneVar protected function Converts the variable into a serializable Data instance.
DataCollector::getCasters protected function 1
DataCollector::reset public function Overrides ResetInterface::reset 11
DataCollector::serialize final protected function @internal to prevent implementing \Serializable
DataCollector::unserialize final protected function @internal to prevent implementing \Serializable
DataCollector::__sleep public function 1
DataCollector::__wakeup public function 1

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal