[ProfilerBundle] refactored some code
This commit is contained in:
parent
74ff6cbd9f
commit
9738f34c4d
@ -58,6 +58,16 @@ class UniversalClassLoader
|
|||||||
protected $namespaces = array();
|
protected $namespaces = array();
|
||||||
protected $prefixes = array();
|
protected $prefixes = array();
|
||||||
|
|
||||||
|
public function getNamespaces()
|
||||||
|
{
|
||||||
|
return $this->namespaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPrefixes()
|
||||||
|
{
|
||||||
|
return $this->prefixes;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an array of namespaces
|
* Registers an array of namespaces
|
||||||
*
|
*
|
||||||
|
@ -26,7 +26,7 @@ class ConfigDataCollector extends DataCollector
|
|||||||
$kernel = $this->container->getKernelService();
|
$kernel = $this->container->getKernelService();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'token' => $this->manager->getRequestDebugData()->getToken(),
|
'token' => $this->manager->getProfilerStorage()->getToken(),
|
||||||
'symfony_version' => Kernel::VERSION,
|
'symfony_version' => Kernel::VERSION,
|
||||||
'name' => $kernel->getName(),
|
'name' => $kernel->getName(),
|
||||||
'env' => $kernel->getEnvironment(),
|
'env' => $kernel->getEnvironment(),
|
||||||
|
@ -5,7 +5,7 @@ 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\ProfilerBundle\RequestDebugData;
|
use Symfony\Framework\ProfilerBundle\ProfilerStorage;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the symfony framework.
|
* This file is part of the symfony framework.
|
||||||
@ -25,16 +25,16 @@ use Symfony\Framework\ProfilerBundle\RequestDebugData;
|
|||||||
class DataCollectorManager
|
class DataCollectorManager
|
||||||
{
|
{
|
||||||
protected $container;
|
protected $container;
|
||||||
protected $requestDebugData;
|
protected $profilerStorage;
|
||||||
protected $collectors;
|
protected $collectors;
|
||||||
protected $response;
|
protected $response;
|
||||||
protected $lifetime;
|
protected $lifetime;
|
||||||
|
|
||||||
public function __construct(ContainerInterface $container, $lifetime = 86400)
|
public function __construct(ContainerInterface $container, ProfilerStorage $profilerStorage, $lifetime = 86400)
|
||||||
{
|
{
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
$this->lifetime = $lifetime;
|
$this->lifetime = $lifetime;
|
||||||
$this->requestDebugData = new RequestDebugData(uniqid(), $this->container->getParameter('kernel.cache_dir').'/debug.db');
|
$this->profilerStorage = $profilerStorage;
|
||||||
$this->collectors = $this->initCollectors();
|
$this->collectors = $this->initCollectors();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,15 +57,15 @@ class DataCollectorManager
|
|||||||
{
|
{
|
||||||
$data[$name] = $collector->getData();
|
$data[$name] = $collector->getData();
|
||||||
}
|
}
|
||||||
$this->requestDebugData->write($data);
|
$this->profilerStorage->write($data);
|
||||||
$this->requestDebugData->purge($this->lifetime);
|
$this->profilerStorage->purge($this->lifetime);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRequestDebugData()
|
public function getProfilerStorage()
|
||||||
{
|
{
|
||||||
return $this->requestDebugData;
|
return $this->profilerStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResponse()
|
public function getResponse()
|
||||||
|
@ -17,16 +17,16 @@ namespace Symfony\Framework\ProfilerBundle;
|
|||||||
* @package symfony
|
* @package symfony
|
||||||
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
||||||
*/
|
*/
|
||||||
class RequestDebugData
|
class ProfilerStorage
|
||||||
{
|
{
|
||||||
protected $token;
|
protected $token;
|
||||||
protected $data;
|
protected $data;
|
||||||
protected $store;
|
protected $store;
|
||||||
|
|
||||||
public function __construct($token, $store)
|
public function __construct($store, $token = null)
|
||||||
{
|
{
|
||||||
$this->token = $token;
|
|
||||||
$this->store = $store;
|
$this->store = $store;
|
||||||
|
$this->token = null === $token ? uniqid() : $token;
|
||||||
$this->data = null;
|
$this->data = null;
|
||||||
}
|
}
|
||||||
|
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
<parameters>
|
<parameters>
|
||||||
<parameter key="data_collector_manager.class">Symfony\Framework\ProfilerBundle\DataCollector\DataCollectorManager</parameter>
|
<parameter key="data_collector_manager.class">Symfony\Framework\ProfilerBundle\DataCollector\DataCollectorManager</parameter>
|
||||||
|
<parameter key="data_collector_manager.storage.class">Symfony\Framework\ProfilerBundle\ProfilerStorage</parameter>
|
||||||
|
<parameter key="data_collector_manager.storage.file">%kernel.cache_dir%/profiler.db</parameter>
|
||||||
<parameter key="data_collector_manager.lifetime">86400</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.config.class">Symfony\Framework\ProfilerBundle\DataCollector\ConfigDataCollector</parameter>
|
||||||
<parameter key="data_collector.app.class">Symfony\Framework\ProfilerBundle\DataCollector\AppDataCollector</parameter>
|
<parameter key="data_collector.app.class">Symfony\Framework\ProfilerBundle\DataCollector\AppDataCollector</parameter>
|
||||||
@ -17,9 +19,14 @@
|
|||||||
<service id="data_collector_manager" class="%data_collector_manager.class%">
|
<service id="data_collector_manager" class="%data_collector_manager.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="data_collector_manager.storage" />
|
||||||
<argument>%data_collector_manager.lifetime%</argument>
|
<argument>%data_collector_manager.lifetime%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service id="data_collector_manager.storage" class="%data_collector_manager.storage.class%">
|
||||||
|
<argument>%data_collector_manager.storage.file%</argument>
|
||||||
|
</service>
|
||||||
|
|
||||||
<service id="data_collector.config" class="%data_collector.config.class%">
|
<service id="data_collector.config" class="%data_collector.config.class%">
|
||||||
<annotation name="data_collector" core="true" />
|
<annotation name="data_collector" core="true" />
|
||||||
<argument type="service" id="service_container" />
|
<argument type="service" id="service_container" />
|
||||||
|
Reference in New Issue
Block a user