Skip to content

Commit

Permalink
[FrameworkBundle] converted the special Profiler class to a DIC compi…
Browse files Browse the repository at this point in the history
…ler class
  • Loading branch information
fabpot committed Dec 23, 2010
1 parent 8e6a384 commit 2985cfa
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;

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

/**
* Adds tagged data_collector services to profiler service
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class ProfilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (false === $container->hasDefinition('profiler')) {
return;
}

$definition = $container->getDefinition('profiler');

foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) {
$definition->addMethodCall('add', array(new Reference($id)));
}
}
}
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddSecurityVotersPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConverterManagerPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\Form\FormConfiguration;
Expand Down Expand Up @@ -46,5 +47,6 @@ public function registerExtensions(ContainerBuilder $container)
$container->addCompilerPass(new AddSecurityVotersPass());
$container->addCompilerPass(new ConverterManagerPass());
$container->addCompilerPass(new RoutingResolverPass());
$container->addCompilerPass(new ProfilerPass());
}
}
34 changes: 0 additions & 34 deletions src/Symfony/Bundle/FrameworkBundle/Profiler.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="profiler.class">Symfony\Bundle\FrameworkBundle\Profiler</parameter>
<parameter key="profiler.class">Symfony\Component\HttpKernel\Profiler\Profiler</parameter>
<parameter key="profiler.storage.class">Symfony\Component\HttpKernel\Profiler\SQLiteProfilerStorage</parameter>
<parameter key="profiler.storage.file">%kernel.cache_dir%/profiler.db</parameter>
<parameter key="profiler.storage.lifetime">86400</parameter>
Expand All @@ -15,7 +15,6 @@

<services>
<service id="profiler" class="%profiler.class%">
<argument type="service" id="service_container" />
<argument type="service" id="profiler.storage" />
<argument type="service" id="logger" on-invalid="null" />
</service>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function testConfigLoad()

// profiler
$loader->configLoad(array('profiler' => true), $container);
$this->assertEquals('Symfony\\Bundle\\FrameworkBundle\\Profiler', $container->getParameter('profiler.class'), '->configLoad() loads the collectors.xml file if not already loaded');
$this->assertEquals('Symfony\Component\HttpKernel\Profiler\Profiler', $container->getParameter('profiler.class'), '->configLoad() loads the collectors.xml file if not already loaded');

// templating
$loader->configLoad(array('templating' => array()), $container);
Expand Down

0 comments on commit 2985cfa

Please sign in to comment.