8000 [ProfilerBundle] refactored some code · CodingFabian/symfony@9738f34 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9738f34

Browse files
committed
[ProfilerBundle] refactored some code
1 parent 74ff6cb commit 9738f34

File tree

5 files changed

+29
-12
lines changed

5 files changed

+29
-12
lines changed

src/Symfony/Foundation/UniversalClassLoader.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ class UniversalClassLoader
5858
protected $namespaces = array();
5959
protected $prefixes = array();
6060

61+
public function getNamespaces()
62+
{
63+
return $this->namespaces;
64+
}
65+
66+
public function getPrefixes()
67+
{
68+
return $this->prefixes;
69+
}
70+
6171
/**
6272
* Registers an array of namespaces
6373
*

src/Symfony/Framework/ProfilerBundle/DataCollector/ConfigDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ protected function collect()
2626
$kernel = $this->container->getKernelService();
2727

2828
return array(
29-
'token' => $this->manager->getRequestDebugData()->getToken(),
29+
'token' => $this->manager->getProfilerStorage()->getToken(),
3030
'symfony_version' => Kernel::VERSION,
3131
'name' => $kernel->getName(),
3232
'env' => $kernel->getEnvironment(),

src/Symfony/Framework/ProfilerBundle/DataCollector/DataCollectorManager.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Symfony\Components\DependencyInjection\ContainerInterface;
66
use Symfony\Components\EventDispatcher\Event;
77
use Symfony\Components\RequestHandler\Response;
8-
use Symfony\Framework\ProfilerBundle\RequestDebugData;
8+
use Symfony\Framework\ProfilerBundle\ProfilerStorage;
99

1010
/*
1111
* This file is part of the symfony framework.
@@ -25,16 +25,16 @@
2525
class DataCollectorManager
2626
{
2727
protected $container;
28-
protected $requestDebugData;
28+
protected $profilerStorage;
2929
protected $collectors;
3030
protected $response;
3131
protected $lifetime;
3232

33-
public function __construct(ContainerInterface $container, $lifetime = 86400)
33+
public function __construct(ContainerInterface $container, ProfilerStorage $profilerStorage, $lifetime = 86400)
3434
{
3535
$this->container = $container;
3636
$this->lifetime = $lifetime;
37-
$this->requestDebugData = new RequestDebugData(uniqid(), $this->container->getParameter('kernel.cache_dir').'/debug.db');
37+
$this->profilerStorage = $profilerStorage;
3838
$this->collectors = $this->initCollectors();
3939
}
4040

@@ -57,15 +57,15 @@ public function handle(Event $event, Response $response)
5757
{
5858
$data[$name] = $collector->getData();
5959
}
60-
$this->requestDebugData->write($data);
61-
$this->requestDebugData->purge($this->lifetime);
60+
$this->profilerStorage->write($data);
61+
$this->profilerStorage->purge($this->lifetime);
6262

6363
return $response;
6464
}
6565

66-
public function getRequestDebugData()
66+
public function getProfilerStorage()
6767
{
68-
return $this->requestDebugData;
68+
return $this->profilerStorage;
6969
}
7070

7171
public function getResponse()

src/Symfony/Framework/ProfilerBundle/RequestDebugData.php renamed to src/Symfony/Framework/ProfilerBundle/ProfilerStorage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@
1717
* @package symfony
1818
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
1919
*/
20-
class RequestDebugData
20+
class ProfilerStorage
2121
{
2222
protected $token;
2323
protected $data;
2424
protected $store;
2525

26-
public function __construct($token, $store)
26+
public function __construct($store, $token = null)
2727
{
28-
$this->token = $token;
2928
$this->store = $store;
29+
$this->token = null === $token ? uniqid() : $token;
3030
$this->data = null;
3131
}
3232

src/Symfony/Framework/ProfilerBundle/Resources/config/collectors.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
<parameters>
88
<parameter key="data_collector_manager.class">Symfony\Framework\ProfilerBundle\DataCollector\DataCollectorManager</parameter>
9+
<parameter key="data_collector_manager.storage.class">Symfony\Framework\ProfilerBundle\ProfilerStorage</parameter>
10+
<parameter key="data_collector_manager.storage.file">%kernel.cache_dir%/profiler.db</parameter>
911
<parameter key="data_collector_manager.lifetime">86400</parameter>
1012
<parameter key="data_collector.config.class">Symfony\Framework\ProfilerBundle\DataCollector\ConfigDataCollector</parameter>
1113
<parameter key="data_collector.app.class">Symfony\Framework\ProfilerBundle\DataCollector\AppDataCollector</parameter>
@@ -17,9 +19,14 @@
1719
<service id="data_collector_manager" class="%data_collector_manager.class%">
1820
<annotation name="kernel.listener" event="core.response" method="handle" />
1921
<argument type="service" id="service_container" />
22+
<argument type="service" id="data_collector_manager.storage" />
2023
<argument>%data_collector_manager.lifetime%</argument>
2124
</service>
2225

26+
<service id="data_collector_manager.storage" class="%data_collector_manager.storage.class%">
27+
<argument>%data_collector_manager.storage.file%</argument>
28+
</service>
29+
2330
<service id="data_collector.config" class="%data_collector.config.class%">
2431
<annotation name="data_collector" core="true" />
2532
<argument type="service" id="service_container" />

0 commit comments

Comments
 (0)
0