Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
made the Kernel dep optional in ConfigDataCollector
  • Loading branch information
fabpot committed Jul 15, 2012
1 parent 0875124 commit dd8a401
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
Expand Up @@ -18,7 +18,7 @@
<services>
<service id="data_collector.config" class="%data_collector.config.class%" public="false">
<tag name="data_collector" template="WebProfilerBundle:Collector:config" id="config" priority="255" />
<argument type="service" id="kernel" />
<call method="setKernel"><argument type="service" id="kernel" /></call>
</service>

<service id="data_collector.request" class="%data_collector.request.class%">
Expand Down
Expand Up @@ -146,19 +146,20 @@
</tr>
</table>

<h2>Active bundles</h2>
<table>
<tr>
<th>Name</th>
<th>Path</th>
</tr>
{% set bundles = collector.bundles %}
{% for name in bundles|keys|sort %}
<tr>
<th>{{ name }}</th>
<td>{{ bundles[name] }}</td>
</tr>
{% endfor %}
</table>

{% if collector.bundles %}
<h2>Active bundles</h2>
<table>
<tr>
<th>Name</th>
<th>Path</th>
</tr>
{% set bundles = collector.bundles %}
{% for name in bundles|keys|sort %}
<tr>
<th>{{ name }}</th>
<td>{{ bundles[name] }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
{% endblock %}
Expand Up @@ -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;
}
Expand All @@ -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'),
Expand All @@ -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();

This comment has been minimized.

Copy link
@stof

stof Jul 15, 2012

Member

this is useless as it is already done line 55

This comment has been minimized.

Copy link
@fabpot

fabpot Jul 15, 2012

Author Member

fixed, thanks.

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

Expand Down
Expand Up @@ -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());
Expand Down

0 comments on commit dd8a401

Please sign in to comment.