/
Profiler.php
56 lines (47 loc) · 1.67 KB
/
Profiler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Symfony\Bundle\FrameworkBundle;
use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\HttpKernel\Profiler\Profiler as BaseProfiler;
use Symfony\Components\HttpKernel\Profiler\ProfilerStorage;
use Symfony\Components\HttpKernel\Log\LoggerInterface;
/*
* 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.
*/
/**
* Profiler.
*
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
*/
class Profiler extends BaseProfiler
{
protected $container;
public function __construct(ContainerInterface $container, ProfilerStorage $profilerStorage, LoggerInterface $logger = null)
{
parent::__construct($profilerStorage, $logger);
$this->container = $container;
$this->initCollectors();
$this->loadCollectorData();
}
protected function initCollectors()
{
$config = $this->container->findTaggedServiceIds('data_collector');
$ids = array();
$coreCollectors = array();
$userCollectors = array();
foreach ($config as $id => $attributes) {
$collector = $this->container->get($id);
$collector->setProfiler($this);
if (isset($attributes[0]['core']) && $attributes[0]['core']) {
$coreCollectors[$collector->getName()] = $collector;
} else {
$userCollectors[$collector->getName()] = $collector;
}
}
$this->setCollectors(array_merge($coreCollectors, $userCollectors));
}
}