Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

file 185 lines (165 sloc) 4.439 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\HttpKernel\DataCollector;

use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* ConfigDataCollector.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ConfigDataCollector extends DataCollector
{
    private $kernel;

    /**
* Constructor.
*
* @param KernelInterface $kernel A KernelInterface instance
*/
    public function __construct(KernelInterface $kernel)
    {
        $this->kernel = $kernel;
    }

    /**
* {@inheritdoc}
*/
    public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        $this->data = array(
            'token' => $response->headers->get('X-Debug-Token'),
            'symfony_version' => Kernel::VERSION,
            'name' => $this->kernel->getName(),
            'env' => $this->kernel->getEnvironment(),
            'debug' => $this->kernel->isDebug(),
            'php_version' => PHP_VERSION,
            'xdebug_enabled' => extension_loaded('xdebug'),
            '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'),
            'bundles' => array(),
        );

        foreach ($this->kernel->getBundles() as $name => $bundle) {
            $this->data['bundles'][$name] = $bundle->getPath();
        }
    }

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

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

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

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

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

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

    /**
* 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 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 XCache is enabled.
*
* @return Boolean true if XCache is enabled, false otherwise
*/
    public function hasXCache()
    {
        return $this->data['xcache_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->hasEAccelerator() || $this->hasXCache();
    }

    public function getBundles()
    {
        return $this->data['bundles'];
    }

    /**
* {@inheritdoc}
*/
    public function getName()
    {
        return 'config';
    }
}
Something went wrong with that request. Please try again.