From 8f24d832333001247aa5692fcb8a58376b145f44 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 4 Apr 2012 08:59:44 -0500 Subject: [PATCH] fixing profiler. --- laravel/profiling/profiler.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/laravel/profiling/profiler.php b/laravel/profiling/profiler.php index 4bd5d863..bb1ed496 100644 --- a/laravel/profiling/profiler.php +++ b/laravel/profiling/profiler.php @@ -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 = '/\(.*)\\<\/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); }); }