Skip to content

Commit a0f42af

Browse files
fbourigaultdbu
authored andcommitted
rewrite all profiler logic (#128)
1 parent 90a9cae commit a0f42af

19 files changed

+1078
-546
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change Log
22

3+
## 1.4.0 - 2017-XX-XX
4+
5+
### Changed
6+
7+
- The profiler collector has been rewritten to use objects instead of arrays.
8+
9+
### Fixed
10+
11+
- WebProfiler is no longer broken when there was a redirect.
312

413
## 1.3.0 - 2016-08-16
514

Collector/Collector.php

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
3+
namespace Http\HttplugBundle\Collector;
4+
5+
use Exception;
6+
use Symfony\Component\HttpFoundation\Request;
7+
use Symfony\Component\HttpFoundation\Response;
8+
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
9+
10+
/**
11+
* The Collector hold profiled Stacks pushed by StackPlugin. It also have a list of configured clients.
12+
* All those data are used to display the HTTPlug panel in the Symfony profiler.
13+
*
14+
* The collector is not designed for execution in a threaded application and does not support plugins that execute an
15+
* other request before the current one is sent by the client.
16+
*
17+
* @author Fabien Bourigault <bourigaultfabien@gmail.com>
18+
*
19+
* @internal
20+
*/
21+
class Collector extends DataCollector
22+
{
23+
/**
24+
* @param array $clients
25+
*/
26+
public function __construct(array $clients)
27+
{
28+
$this->data['stacks'] = [];
29+
$this->data['clients'] = $clients;
30+
}
31+
32+
/**
33+
* {@inheritdoc}
34+
*/
35+
public function collect(Request $request, Response $response, Exception $exception = null)
36+
{
37+
// We do not need to collect any data from the Symfony Request and Response
38+
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*/
43+
public function getName()
44+
{
45+
return 'httplug';
46+
}
47+
48+
/**
49+
* @param Stack $stack
50+
*/
51+
public function addStack(Stack $stack)
52+
{
53+
$this->data['stacks'][] = $stack;
54+
}
55+
56+
/**
57+
* @return Stack[]
58+
*/
59+
public function getStacks()
60+
{
61+
return $this->data['stacks'];
62+
}
63+
64+
/**
65+
* @return Stack
66+
*/
67+
public function getCurrentStack()
68+
{
69+
return end($this->data['stacks']);
70+
}
71+
72+
/**
73+
* @return Stack[]
74+
*/
75+
public function getSuccessfulStacks()
76+
{
77+
return array_filter($this->data['stacks'], function (Stack $stack) {
78+
return !$stack->isFailed();
79+
});
80+
}
81+
82+
/**
83+
* @return Stack[]
84+
*/
85+
public function getFailedStacks()
86+
{
87+
return array_filter($this->data['stacks'], function (Stack $stack) {
88+
return $stack->isFailed();
89+
});
90+
}
91+
92+
/**
93+
* @return array
94+
*/
95+
public function getClients()
96+
{
97+
return $this->data['clients'];
98+
}
99+
100+
/**
101+
* @param $client
102+
*
103+
* @return Stack[]
104+
*/
105+
public function getClientStacks($client)
106+
{
107+
return array_filter($this->data['stacks'], function (Stack $stack) use ($client) {
108+
return $stack->getClient() == $client;
109+
});
110+
}
111+
}

Collector/DebugPlugin.php

Lines changed: 0 additions & 63 deletions
This file was deleted.

Collector/DebugPluginCollector.php

Lines changed: 0 additions & 181 deletions
This file was deleted.

0 commit comments

Comments
 (0)