[ProfiledBundle] moved debug tools from WebBundle to ProfilerBundle

This commit is contained in:
Fabien Potencier 2010-03-01 12:47:28 +01:00
parent 3fbe294461
commit 2e420c3c8a
23 changed files with 192 additions and 97 deletions

View File

@ -1,8 +1,8 @@
<?php <?php
namespace Symfony\Framework\DoctrineBundle\Debug; namespace Symfony\Framework\DoctrineBundle\DataCollector;
use Symfony\Framework\WebBundle\Debug\DataCollector\DataCollector; use Symfony\Framework\ProfilerBundle\DataCollector\DataCollector;
/* /*
* This file is part of the symfony framework. * This file is part of the symfony framework.

View File

@ -5,9 +5,7 @@
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd"> xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd">
<parameters> <parameters>
<parameter key="doctrine.debug.collector.class"> <parameter key="doctrine.data_collector.class">Symfony\Framework\DoctrineBundle\DataCollector\DoctrineDataCollector</parameter>
Symfony\Framework\DoctrineBundle\Debug\DoctrineDataCollector
</parameter>
</parameters> </parameters>
<services> <services>
@ -17,8 +15,8 @@
<argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="logger" on-invalid="null" />
</service> </service>
<service id="doctrine.debug.collector" class="%doctrine.debug.collector.class%"> <service id="doctrine.data_collector" class="%doctrine.data_collector.class%">
<annotation name="debug.collector" /> <annotation name="data_collector" />
<argument type="service" id="service_container" /> <argument type="service" id="service_container" />
</service> </service>
</services> </services>

View File

@ -0,0 +1,31 @@
<?php
namespace Symfony\Framework\ProfilerBundle;
use Symfony\Foundation\Bundle\Bundle as BaseBundle;
use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\DependencyInjection\Loader\Loader;
use Symfony\Framework\ProfilerBundle\DependencyInjection\ProfilerExtension;
/*
* This file is part of the symfony framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
*
*
* @package symfony
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class Bundle extends BaseBundle
{
public function buildContainer(ContainerInterface $container)
{
Loader::registerExtension(new ProfilerExtension());
}
}

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Symfony\Framework\WebBundle\Debug\DataCollector; namespace Symfony\Framework\ProfilerBundle\DataCollector;
/* /*
* This file is part of the symfony framework. * This file is part of the symfony framework.

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Symfony\Framework\WebBundle\Debug\DataCollector; namespace Symfony\Framework\ProfilerBundle\DataCollector;
use Symfony\Foundation\Kernel; use Symfony\Foundation\Kernel;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Symfony\Framework\WebBundle\Debug\DataCollector; namespace Symfony\Framework\ProfilerBundle\DataCollector;
use Symfony\Components\DependencyInjection\ContainerInterface; use Symfony\Components\DependencyInjection\ContainerInterface;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Symfony\Framework\WebBundle\Debug\DataCollector; namespace Symfony\Framework\ProfilerBundle\DataCollector;
/* /*
* This file is part of the symfony framework. * This file is part of the symfony framework.

View File

@ -1,11 +1,11 @@
<?php <?php
namespace Symfony\Framework\WebBundle\Debug\DataCollector; namespace Symfony\Framework\ProfilerBundle\DataCollector;
use Symfony\Components\DependencyInjection\ContainerInterface; use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\EventDispatcher\Event; use Symfony\Components\EventDispatcher\Event;
use Symfony\Components\RequestHandler\Response; use Symfony\Components\RequestHandler\Response;
use Symfony\Framework\WebBundle\Debug\RequestDebugData; use Symfony\Framework\ProfilerBundle\RequestDebugData;
/* /*
* This file is part of the symfony framework. * This file is part of the symfony framework.
@ -80,7 +80,7 @@ class DataCollectorManager
public function initCollectors() public function initCollectors()
{ {
$config = $this->container->findAnnotatedServiceIds('debug.collector'); $config = $this->container->findAnnotatedServiceIds('data_collector');
$ids = array(); $ids = array();
$coreColectors = array(); $coreColectors = array();
$userCollectors = array(); $userCollectors = array();

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Symfony\Framework\WebBundle\Debug\DataCollector; namespace Symfony\Framework\ProfilerBundle\DataCollector;
/* /*
* This file is part of the symfony framework. * This file is part of the symfony framework.

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Symfony\Framework\WebBundle\Debug\DataCollector; namespace Symfony\Framework\ProfilerBundle\DataCollector;
/* /*
* This file is part of the symfony framework. * This file is part of the symfony framework.

View File

@ -0,0 +1,60 @@
<?php
namespace Symfony\Framework\ProfilerBundle\DependencyInjection;
use Symfony\Components\DependencyInjection\Loader\LoaderExtension;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Components\DependencyInjection\BuilderConfiguration;
/*
* This file is part of the symfony framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
* ProfilerExtension manages the data collectors and the web debug toolbar.
*
* @package symfony
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class ProfilerExtension extends LoaderExtension
{
public function configLoad($config)
{
$configuration = new BuilderConfiguration();
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$configuration->merge($loader->load('collectors.xml'));
if (isset($config['toolbar']) && $config['toolbar'])
{
$configuration->merge($loader->load('toolbar.xml'));
}
return $configuration;
}
/**
* Returns the base path for the XSD files.
*
* @return string The XSD base path
*/
public function getXsdValidationBasePath()
{
return __DIR__.'/../Resources/config/';
}
public function getNamespace()
{
return 'http://www.symfony-project.org/schema/dic/symfony/profiler';
}
public function getAlias()
{
return 'profiler';
}
}

View File

@ -1,11 +1,11 @@
<?php <?php
namespace Symfony\Framework\WebBundle\Debug; namespace Symfony\Framework\ProfilerBundle\Listener;
use Symfony\Components\DependencyInjection\ContainerInterface; use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\EventDispatcher\Event; use Symfony\Components\EventDispatcher\Event;
use Symfony\Components\RequestHandler\Response; use Symfony\Components\RequestHandler\Response;
use Symfony\Framework\WebBundle\Debug\DataCollector\DataCollectorManager; use Symfony\Framework\ProfilerBundle\DataCollector\DataCollectorManager;
/* /*
* This file is part of the symfony framework. * This file is part of the symfony framework.

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Symfony\Framework\WebBundle\Debug; namespace Symfony\Framework\ProfilerBundle;
/* /*
* This file is part of the symfony framework. * This file is part of the symfony framework.

View File

@ -0,0 +1,43 @@
<?xml version="1.0" ?>
<container xmlns="http://www.symfony-project.org/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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="data_collector_manager.class">Symfony\Framework\ProfilerBundle\DataCollector\DataCollectorManager</parameter>
<parameter key="data_collector_manager.lifetime">86400</parameter>
<parameter key="data_collector.config.class">Symfony\Framework\ProfilerBundle\DataCollector\ConfigDataCollector</parameter>
<parameter key="data_collector.app.class">Symfony\Framework\ProfilerBundle\DataCollector\AppDataCollector</parameter>
<parameter key="data_collector.timer.class">Symfony\Framework\ProfilerBundle\DataCollector\TimerDataCollector</parameter>
<parameter key="data_collector.memory.class">Symfony\Framework\ProfilerBundle\DataCollector\MemoryDataCollector</parameter>
</parameters>
<services>
<service id="data_collector_manager" class="%data_collector_manager.class%">
<annotation name="kernel.listener" event="core.response" method="handle" />
<argument type="service" id="service_container" />
<argument>%data_collector_manager.lifetime%</argument>
</service>
<service id="data_collector.config" class="%data_collector.config.class%">
<annotation name="data_collector" core="true" />
<argument type="service" id="service_container" />
</service>
<service id="data_collector.app" class="%data_collector.app.class%">
<annotation name="data_collector" core="true" />
<argument type="service" id="service_container" />
</service>
<service id="data_collector.timer" class="%data_collector.timer.class%">
<annotation name="data_collector" core="true" />
<argument type="service" id="service_container" />
</service>
<service id="data_collector.memory" class="%data_collector.memory.class%">
<annotation name="data_collector" core="true" />
<argument type="service" id="service_container" />
</service>
</services>
</container>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns="http://www.symfony-project.org/schema/dic/symfony/profiler"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.symfony-project.org/schema/dic/symfony/profiler"
elementFormDefault="qualified">
<xsd:element name="config" type="config" />
<xsd:complexType name="config">
<xsd:attribute name="toolbar" type="xsd:boolean" />
</xsd:complexType>
</xsd:schema>

View File

@ -5,14 +5,14 @@
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd"> xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd">
<parameters> <parameters>
<parameter key="debug.web_debug_toolbar.class">Symfony\Framework\WebBundle\Debug\WebDebugToolbar</parameter> <parameter key="debug.toolbar.class">Symfony\Framework\ProfilerBundle\Listener\WebDebugToolbar</parameter>
</parameters> </parameters>
<services> <services>
<service id="debug.web_debug_toolbar" class="%debug.web_debug_toolbar.class%"> <service id="debug.toolbar" class="%debug.toolbar.class%">
<annotation name="kernel.listener" event="core.response" method="handle" /> <annotation name="kernel.listener" event="core.response" method="handle" />
<argument type="service" id="service_container" /> <argument type="service" id="service_container" />
<argument type="service" id="debug.data_collector_manager" /> <argument type="service" id="data_collector_manager" />
</service> </service>
</services> </services>
</container> </container>

View File

@ -27,7 +27,6 @@ class WebExtension extends LoaderExtension
protected $resources = array( protected $resources = array(
'templating' => 'templating.xml', 'templating' => 'templating.xml',
'web' => 'web.xml', 'web' => 'web.xml',
'debug' => 'debug.xml',
'user' => 'user.xml', 'user' => 'user.xml',
); );
@ -147,20 +146,6 @@ class WebExtension extends LoaderExtension
return $configuration; return $configuration;
} }
public function debugLoad($config)
{
$configuration = new BuilderConfiguration();
if (isset($config['toolbar']) && $config['toolbar'])
{
$loader = new XmlFileLoader(__DIR__.'/../Resources/config');
$configuration->merge($loader->load('debug_data_collector.xml'));
$configuration->merge($loader->load('debug_web_debug_toolbar.xml'));
}
return $configuration;
}
/** /**
* Returns the base path for the XSD files. * Returns the base path for the XSD files.
* *

View File

@ -1,43 +0,0 @@
<?xml version="1.0" ?>
<container xmlns="http://www.symfony-project.org/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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="debug.data_collector_manager.class">Symfony\Framework\WebBundle\Debug\DataCollector\DataCollectorManager</parameter>
<parameter key="debug.data_collector_manager.lifetime">86400</parameter>
<parameter key="debug.data_collector.config.class">Symfony\Framework\WebBundle\Debug\DataCollector\ConfigDataCollector</parameter>
<parameter key="debug.data_collector.app.class">Symfony\Framework\WebBundle\Debug\DataCollector\AppDataCollector</parameter>
<parameter key="debug.data_collector.timer.class">Symfony\Framework\WebBundle\Debug\DataCollector\TimerDataCollector</parameter>
<parameter key="debug.data_collector.memory.class">Symfony\Framework\WebBundle\Debug\DataCollector\MemoryDataCollector</parameter>
</parameters>
<services>
<service id="debug.data_collector_manager" class="%debug.data_collector_manager.class%">
<annotation name="kernel.listener" event="core.response" method="handle" />
<argument type="service" id="service_container" />
<argument>%debug.data_collector_manager.lifetime%</argument>
</service>
<service id="debug.data_collector.config" class="%debug.data_collector.config.class%">
<annotation name="debug.collector" core="true" />
<argument type="service" id="service_container" />
</service>
<service id="debug.data_collector.app" class="%debug.data_collector.app.class%">
<annotation name="debug.collector" core="true" />
<argument type="service" id="service_container" />
</service>
<service id="debug.data_collector.timer" class="%debug.data_collector.timer.class%">
<annotation name="debug.collector" core="true" />
<argument type="service" id="service_container" />
</service>
<service id="debug.data_collector.memory" class="%debug.data_collector.memory.class%">
<annotation name="debug.collector" core="true" />
<argument type="service" id="service_container" />
</service>
</services>
</container>

View File

@ -8,7 +8,6 @@
<xsd:element name="web" type="web" /> <xsd:element name="web" type="web" />
<xsd:element name="templating" type="templating" /> <xsd:element name="templating" type="templating" />
<xsd:element name="user" type="user" /> <xsd:element name="user" type="user" />
<xsd:element name="debug" type="debug" />
<xsd:complexType name="user"> <xsd:complexType name="user">
<xsd:sequence> <xsd:sequence>
@ -45,8 +44,4 @@
<xsd:attribute name="path" type="xsd:string" /> <xsd:attribute name="path" type="xsd:string" />
<xsd:attribute name="cache" type="xsd:string" /> <xsd:attribute name="cache" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
<xsd:complexType name="debug">
<xsd:attribute name="toolbar" type="xsd:string" />
</xsd:complexType>
</xsd:schema> </xsd:schema>

View File

@ -16,7 +16,7 @@ class {{ class }}Kernel extends Kernel
public function registerBundles() public function registerBundles()
{ {
return array( $bundles = array(
new Symfony\Foundation\Bundle\KernelBundle(), new Symfony\Foundation\Bundle\KernelBundle(),
new Symfony\Framework\WebBundle\Bundle(), new Symfony\Framework\WebBundle\Bundle(),
@ -27,6 +27,13 @@ class {{ class }}Kernel extends Kernel
// register your bundles here // register your bundles here
); );
if ($this->isDebug())
{
$bundles[] = new Symfony\Framework\ProfilerBundle\Bundle();
}
return $bundles;
} }
public function registerBundleDirs() public function registerBundleDirs()

View File

@ -4,20 +4,21 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:zend="http://www.symfony-project.org/schema/dic/zend" xmlns:zend="http://www.symfony-project.org/schema/dic/zend"
xmlns:web="http://www.symfony-project.org/schema/dic/symfony" xmlns:web="http://www.symfony-project.org/schema/dic/symfony"
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd"> xmlns:profiler="http://www.symfony-project.org/schema/dic/symfony/profiler"
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd
http://www.symfony-project.org/schema/dic/zend http://www.symfony-project.org/schema/dic/zend/zend-1.0.xsd
http://www.symfony-project.org/schema/dic/symfony/profiler http://www.symfony-project.org/schema/dic/symfony/profiler-1.0.xsd">
<imports> <imports>
<import resource="config.xml" /> <import resource="config.xml" />
</imports> </imports>
<zend:logger <zend:logger
priority="debug" priority="info"
path="%kernel.logs_dir%/%kernel.environment%.log" path="%kernel.logs_dir%/%kernel.environment%.log"
/> />
<web:debug <profiler:config
exception="%kernel.debug%" toolbar="true"
toolbar="%kernel.debug%"
ide="textmate"
/> />
</container> </container>

View File

@ -16,7 +16,7 @@ class {{ class }}Kernel extends Kernel
public function registerBundles() public function registerBundles()
{ {
return array( $bundles = array(
new Symfony\Foundation\Bundle\KernelBundle(), new Symfony\Foundation\Bundle\KernelBundle(),
new Symfony\Framework\WebBundle\Bundle(), new Symfony\Framework\WebBundle\Bundle(),
@ -27,6 +27,13 @@ class {{ class }}Kernel extends Kernel
// register your bundles here // register your bundles here
); );
if ($this->isDebug())
{
$bundles[] = new Symfony\Framework\ProfilerBundle\Bundle();
}
return $bundles;
} }
public function registerBundleDirs() public function registerBundleDirs()

View File

@ -5,7 +5,5 @@ zend.logger:
priority: debug priority: debug
path: %kernel.logs_dir%/%kernel.environment%.log path: %kernel.logs_dir%/%kernel.environment%.log
web.debug: profiler.config:
exception: %kernel.debug% toolbar: true
toolbar: %kernel.debug%
ide: textmate