diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml index 33763c382396..d3956ee7263e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml @@ -18,7 +18,7 @@ - + diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 33733b1111b4..2e1428f33723 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -146,19 +146,20 @@ -

Active bundles

- - - - - - {% set bundles = collector.bundles %} - {% for name in bundles|keys|sort %} - - - - - {% endfor %} -
NamePath
{{ name }}{{ bundles[name] }}
- + {% if collector.bundles %} +

Active bundles

+ + + + + + {% set bundles = collector.bundles %} + {% for name in bundles|keys|sort %} + + + + + {% endfor %} +
NamePath
{{ name }}{{ bundles[name] }}
+ {% endif %} {% endblock %} diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 37e93b05288a..61b22f131a27 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -31,7 +31,7 @@ class ConfigDataCollector extends DataCollector * * @param KernelInterface $kernel A KernelInterface instance */ - public function __construct(KernelInterface $kernel) + public function setKernel(KernelInterface $kernel) { $this->kernel = $kernel; } @@ -44,9 +44,9 @@ public function collect(Request $request, Response $response, \Exception $except $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(), + 'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a', + 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', + 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => PHP_VERSION, 'xdebug_enabled' => extension_loaded('xdebug'), 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), @@ -55,8 +55,11 @@ public function collect(Request $request, Response $response, \Exception $except 'bundles' => array(), ); - foreach ($this->kernel->getBundles() as $name => $bundle) { - $this->data['bundles'][$name] = $bundle->getPath(); + $this->data['bundles'] = array(); + if (isset($this->kernel)) { + foreach ($this->kernel->getBundles() as $name => $bundle) { + $this->data['bundles'][$name] = $bundle->getPath(); + } } } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 407f18fec034..f517c12b2f92 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -28,8 +28,9 @@ protected function setUp() public function testCollect() { - $kernel = new KernelForTest('test',true); - $c = new ConfigDataCollector($kernel); + $kernel = new KernelForTest('test', true); + $c = new ConfigDataCollector(); + $c->setKernel($kernel); $c->collect(new Request(), new Response()); $this->assertSame('test',$c->getEnv());