[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
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.

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">
<parameters>
<parameter key="doctrine.debug.collector.class">
Symfony\Framework\DoctrineBundle\Debug\DoctrineDataCollector
</parameter>
<parameter key="doctrine.data_collector.class">Symfony\Framework\DoctrineBundle\DataCollector\DoctrineDataCollector</parameter>
</parameters>
<services>
@ -17,8 +15,8 @@
<argument type="service" id="logger" on-invalid="null" />
</service>
<service id="doctrine.debug.collector" class="%doctrine.debug.collector.class%">
<annotation name="debug.collector" />
<service id="doctrine.data_collector" class="%doctrine.data_collector.class%">
<annotation name="data_collector" />
<argument type="service" id="service_container" />
</service>
</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
namespace Symfony\Framework\WebBundle\Debug\DataCollector;
namespace Symfony\Framework\ProfilerBundle\DataCollector;
/*
* This file is part of the symfony framework.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
<?php
namespace Symfony\Framework\WebBundle\Debug\DataCollector;
namespace Symfony\Framework\ProfilerBundle\DataCollector;
/*
* 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
namespace Symfony\Framework\WebBundle\Debug;
namespace Symfony\Framework\ProfilerBundle\Listener;
use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\EventDispatcher\Event;
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.

View File

@ -1,6 +1,6 @@
<?php
namespace Symfony\Framework\WebBundle\Debug;
namespace Symfony\Framework\ProfilerBundle;
/*
* 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">
<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>
<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" />
<argument type="service" id="service_container" />
<argument type="service" id="debug.data_collector_manager" />
<argument type="service" id="data_collector_manager" />
</service>
</services>
</container>

View File

@ -27,7 +27,6 @@ class WebExtension extends LoaderExtension
protected $resources = array(
'templating' => 'templating.xml',
'web' => 'web.xml',
'debug' => 'debug.xml',
'user' => 'user.xml',
);
@ -147,20 +146,6 @@ class WebExtension extends LoaderExtension
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.
*

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

View File

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

View File

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

View File

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

View File

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