From 9738f34c4d01b9fa378f7ad472e613253fe9c35a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 1 Mar 2010 19:10:47 +0100 Subject: [PATCH] [ProfilerBundle] refactored some code --- src/Symfony/Foundation/UniversalClassLoader.php | 10 ++++++++++ .../DataCollector/ConfigDataCollector.php | 2 +- .../DataCollector/DataCollectorManager.php | 16 ++++++++-------- ...{RequestDebugData.php => ProfilerStorage.php} | 6 +++--- .../Resources/config/collectors.xml | 7 +++++++ 5 files changed, 29 insertions(+), 12 deletions(-) rename src/Symfony/Framework/ProfilerBundle/{RequestDebugData.php => ProfilerStorage.php} (93%) diff --git a/src/Symfony/Foundation/UniversalClassLoader.php b/src/Symfony/Foundation/UniversalClassLoader.php index 90591b38f9..11bdbcf658 100644 --- a/src/Symfony/Foundation/UniversalClassLoader.php +++ b/src/Symfony/Foundation/UniversalClassLoader.php @@ -58,6 +58,16 @@ class UniversalClassLoader protected $namespaces = array(); protected $prefixes = array(); + public function getNamespaces() + { + return $this->namespaces; + } + + public function getPrefixes() + { + return $this->prefixes; + } + /** * Registers an array of namespaces * diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/ConfigDataCollector.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/ConfigDataCollector.php index 293faea74c..32cbbbd28b 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/ConfigDataCollector.php @@ -26,7 +26,7 @@ class ConfigDataCollector extends DataCollector $kernel = $this->container->getKernelService(); return array( - 'token' => $this->manager->getRequestDebugData()->getToken(), + 'token' => $this->manager->getProfilerStorage()->getToken(), 'symfony_version' => Kernel::VERSION, 'name' => $kernel->getName(), 'env' => $kernel->getEnvironment(), diff --git a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php index d2192b4750..bd23e5f384 100644 --- a/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php +++ b/src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php @@ -5,7 +5,7 @@ namespace Symfony\Framework\ProfilerBundle\DataCollector; use Symfony\Components\DependencyInjection\ContainerInterface; use Symfony\Components\EventDispatcher\Event; use Symfony\Components\RequestHandler\Response; -use Symfony\Framework\ProfilerBundle\RequestDebugData; +use Symfony\Framework\ProfilerBundle\ProfilerStorage; /* * This file is part of the symfony framework. @@ -25,16 +25,16 @@ use Symfony\Framework\ProfilerBundle\RequestDebugData; class DataCollectorManager { protected $container; - protected $requestDebugData; + protected $profilerStorage; protected $collectors; protected $response; protected $lifetime; - public function __construct(ContainerInterface $container, $lifetime = 86400) + public function __construct(ContainerInterface $container, ProfilerStorage $profilerStorage, $lifetime = 86400) { $this->container = $container; $this->lifetime = $lifetime; - $this->requestDebugData = new RequestDebugData(uniqid(), $this->container->getParameter('kernel.cache_dir').'/debug.db'); + $this->profilerStorage = $profilerStorage; $this->collectors = $this->initCollectors(); } @@ -57,15 +57,15 @@ class DataCollectorManager { $data[$name] = $collector->getData(); } - $this->requestDebugData->write($data); - $this->requestDebugData->purge($this->lifetime); + $this->profilerStorage->write($data); + $this->profilerStorage->purge($this->lifetime); return $response; } - public function getRequestDebugData() + public function getProfilerStorage() { - return $this->requestDebugData; + return $this->profilerStorage; } public function getResponse() diff --git a/src/Symfony/Framework/ProfilerBundle/RequestDebugData.php b/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php similarity index 93% rename from src/Symfony/Framework/ProfilerBundle/RequestDebugData.php rename to src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php index bf8dc05dd9..09ebb73f80 100644 --- a/src/Symfony/Framework/ProfilerBundle/RequestDebugData.php +++ b/src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php @@ -17,16 +17,16 @@ namespace Symfony\Framework\ProfilerBundle; * @package symfony * @author Fabien Potencier */ -class RequestDebugData +class ProfilerStorage { protected $token; protected $data; protected $store; - public function __construct($token, $store) + public function __construct($store, $token = null) { - $this->token = $token; $this->store = $store; + $this->token = null === $token ? uniqid() : $token; $this->data = null; } diff --git a/src/Symfony/Framework/ProfilerBundle/Resources/config/collectors.xml b/src/Symfony/Framework/ProfilerBundle/Resources/config/collectors.xml index a2c6b18f5a..6547c2bd1f 100644 --- a/src/Symfony/Framework/ProfilerBundle/Resources/config/collectors.xml +++ b/src/Symfony/Framework/ProfilerBundle/Resources/config/collectors.xml @@ -6,6 +6,8 @@ Symfony\Framework\ProfilerBundle\DataCollector\DataCollectorManager + Symfony\Framework\ProfilerBundle\ProfilerStorage + %kernel.cache_dir%/profiler.db 86400 Symfony\Framework\ProfilerBundle\DataCollector\ConfigDataCollector Symfony\Framework\ProfilerBundle\DataCollector\AppDataCollector @@ -17,9 +19,14 @@ + %data_collector_manager.lifetime% + + %data_collector_manager.storage.file% + +