Skip to content

Commit

Permalink
Added Response Header Profiling #15
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Jan 12, 2017
1 parent 19c0e7b commit 4edf715
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Resources/views/frontend/profiler/tabs/request.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
{foreach from=$sDetail.response.headers key=key item=value}
<tr>
<td>{$key}</td>
<td>{$value}</td>
<td>{$value|@implode:" "}</td>
</tr>
{/foreach}
</tbody>
Expand Down
12 changes: 9 additions & 3 deletions Subscriber/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

use Enlight\Event\SubscriberInterface;
use Enlight_Controller_Action;
use Enlight_Controller_Response_ResponseHttp;
use Shopware\Components\DependencyInjection\Container;
use Symfony\Component\HttpFoundation\Response;

class Collector implements SubscriberInterface
{
Expand Down Expand Up @@ -131,6 +133,12 @@ public function onDispatchLoopShutdown(\Enlight_Event_EventArgs $args)
return;
}

/** @var Enlight_Controller_Response_ResponseHttp $response */
$response = $args->get('response');

/** @var Response $symfonyResponse */
$symfonyResponse = $this->container->get('kernel')->transformEnlightResponseToSymfonyResponse($response);

$profileTemplate = [];
$profileTemplate['renderedTemplates'] = $this->renderedTemplates;
$profileTemplate['blockCalls'] = $this->blockCalls;
Expand All @@ -140,6 +148,7 @@ public function onDispatchLoopShutdown(\Enlight_Event_EventArgs $args)
$profileData = $this->container->get('shyim_profiler.collector')->collectInformation($this->profileController);
$profileData['template'] = array_merge($profileData['template'], $profileTemplate);
$profileData['mails'] = $this->mails;
$profileData['response']['headers'] = $symfonyResponse->headers->all();

$isIPWhitelisted = in_array(Shopware()->Front()->Request()->getClientIp(), explode("\n", $this->pluginConfig['whitelistIP']));

Expand All @@ -161,9 +170,6 @@ public function onDispatchLoopShutdown(\Enlight_Event_EventArgs $args)
$view->addTemplateDir($this->container->getParameter('shyim_profiler.plugin_dir') . '/Resources/views/');
$profileTemplate = $view->fetch('@Profiler/index.tpl');

/** @var \Enlight_Controller_Response_ResponseHttp $response */
$response = $args->get('response');

$content = $response->getBody();

$content = str_replace('</body>', $profileTemplate . '</body>', $content);
Expand Down

0 comments on commit 4edf715

Please sign in to comment.