fixing profiler.

This commit is contained in:
Taylor Otwell 2012-04-04 08:59:44 -05:00
parent 17bd505ff6
commit 8f24d83233
1 changed files with 19 additions and 2 deletions

View File

@ -18,10 +18,14 @@ class Profiler {
/**
* Get the rendered contents of the Profiler.
*
* @param Response $response
* @return string
*/
public static function render()
public static function render($response)
{
// We only want to send the profiler toolbar if the request is not an AJAX
// request, as sending it on AJAX requests could mess up JSON driven API
// type applications, so we will not send anything in those scenarios.
if ( ! Request::ajax())
{
return render('path: '.__DIR__.'/template'.BLADE_EXT, static::$data);
@ -56,6 +60,19 @@ public static function query($sql, $bindings, $time)
static::$data['queries'][] = array($sql, $time);
}
/**
* Determine if the given response includes jQuery.
*
* @param Response $response
* @return bool
*/
protected static function has_jquery($response)
{
$pattern = '/\<head>(.*)\<script(.+)jquery(.*)\>\<\/script\>(.*)\<\/head\>/';
return preg_match($pattern, $response->content);
}
/**
* Attach the Profiler's event listeners.
*
@ -81,7 +98,7 @@ public static function attach()
// browser. This will display the profiler's nice toolbar.
Event::listen('laravel.done', function($response)
{
echo Profiler::render();
echo Profiler::render($response);
});
}