Skip to content

Fix profiler for plugins like redirect #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Change Log

## 1.4.0 - 2017-XX-XX

### Changed

- The profiler collector has been rewritten to use objects instead of arrays.

### Fixed

- WebProfiler is no longer broken when there was a redirect.

## 1.3.0 - 2016-08-16

Expand Down
111 changes: 111 additions & 0 deletions Collector/Collector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace Http\HttplugBundle\Collector;

use Exception;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;

/**
* The Collector hold profiled Stacks pushed by StackPlugin. It also have a list of configured clients.
* All those data are used to display the HTTPlug panel in the Symfony profiler.
*
* The collector is not designed for execution in a threaded application and does not support plugins that execute an
* other request before the current one is sent by the client.
*
* @author Fabien Bourigault <bourigaultfabien@gmail.com>
*
* @internal
*/
class Collector extends DataCollector
{
/**
* @param array $clients
*/
public function __construct(array $clients)
{
$this->data['stacks'] = [];
$this->data['clients'] = $clients;
}

/**
* {@inheritdoc}
*/
public function collect(Request $request, Response $response, Exception $exception = null)
{
// We do not need to collect any data from the Symfony Request and Response
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'httplug';
}

/**
* @param Stack $stack
*/
public function addStack(Stack $stack)
{
$this->data['stacks'][] = $stack;
}

/**
* @return Stack[]
*/
public function getStacks()
{
return $this->data['stacks'];
}

/**
* @return Stack
*/
public function getCurrentStack()
{
return end($this->data['stacks']);
}

/**
* @return Stack[]
*/
public function getSuccessfulStacks()
{
return array_filter($this->data['stacks'], function (Stack $stack) {
return !$stack->isFailed();
});
}

/**
* @return Stack[]
*/
public function getFailedStacks()
{
return array_filter($this->data['stacks'], function (Stack $stack) {
return $stack->isFailed();
});
}

/**
* @return array
*/
public function getClients()
{
return $this->data['clients'];
}

/**
* @param $client
*
* @return Stack[]
*/
public function getClientStacks($client)
{
return array_filter($this->data['stacks'], function (Stack $stack) use ($client) {
return $stack->getClient() == $client;
});
}
}
63 changes: 0 additions & 63 deletions Collector/DebugPlugin.php

This file was deleted.

181 changes: 0 additions & 181 deletions Collector/DebugPluginCollector.php

This file was deleted.

Loading