Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #8 from mariano/i7

Fixes #7: notices when toolbar does not need to be shown
  • Loading branch information...
commit 9c1dd55cc0d8d0d5087f23040d4c7f65aa51866c 2 parents c9b25f9 + 1ad971d
@tmaiaroto authored
Showing with 45 additions and 35 deletions.
  1. +45 −35 config/bootstrap/dispatcher.php
View
80 config/bootstrap/dispatcher.php
@@ -51,15 +51,56 @@
// Render the toolbar (unless it's an asset from the li3_perf library)
// Why? See li3_perf\extensions\util\Asset
if(!isset($params['request']->params['asset_type'])) {
+ $skip = false;
+ $li3_perf = Libraries::get('li3_perf');
+ if(isset($li3_perf['skip'])) {
+ $controller = isset($params['request']->params['controller']) ? $params['request']->params['controller']:null;
+ $action = isset($params['request']->params['action']) ? $params['request']->params['action']:null;
+ $library = isset($params['request']->params['library']) ? $params['request']->params['library']:null;
+
+ // Check to see if the toolbar should be shown for this library
+ if(isset($li3_perf['skip']['library'])) {
+ if(in_array($library, $li3_perf['skip']['library'])) {
+ $skip = true;
+ }
+ }
+
+ // Check to see if the toolbar should be shown for this controller
+ if(isset($li3_perf['skip']['controller'])) {
+ if(in_array($controller, $li3_perf['skip']['controller'])) {
+ $skip = true;
+ }
+ }
+
+ // Check to see if the toolbar should be shown for this action
+ if(isset($li3_perf['skip']['action'])) {
+ if(in_array($action, $li3_perf['skip']['action'])) {
+ $skip = true;
+ }
+ }
+ }
+
+ if ($skip || !isset($result->body[0])) {
+ return $result;
+ }
+
+ $timers = Data::get('timers') + array(
+ 'li3_perf_start' => 0,
+ 'li3_perf_end' => 0,
+ 'li3_perf_start_dispatch' => 0,
+ 'li3_perf_has_route' => 0,
+ 'li3_perf_start_call' => 0,
+ 'li3_perf_end_call' => 0,
+ '_filter_for_variables' => 0,
+ '_filter_for_queries' => 0
+ );
+
$View = new View(array(
'paths' => array(
'template' => '{:library}/views/elements/{:template}.{:type}.php',
'layout' => '{:library}/views/layouts/{:layout}.{:type}.php',
)
));
-
- $timers = Data::get('timers');
-
$toolbar = $View->render('all',
array(
'timers' => $timers += array(
@@ -87,38 +128,7 @@
// There are sometimes issues with the headers already being sent otherwise.
// TODO: IF proper HTML were to be desired, perhaps insert $toolbar into the body in the
// proper spot within the HTML.
- $skip = false;
- $li3_perf = Libraries::get('li3_perf');
- if(isset($li3_perf['skip'])) {
- $controller = isset($params['request']->params['controller']) ? $params['request']->params['controller']:null;
- $action = isset($params['request']->params['action']) ? $params['request']->params['action']:null;
- $library = isset($params['request']->params['library']) ? $params['request']->params['library']:null;
-
- // Check to see if the toolbar should be shown for this library
- if(isset($li3_perf['skip']['library'])) {
- if(in_array($library, $li3_perf['skip']['library'])) {
- $skip = true;
- }
- }
-
- // Check to see if the toolbar should be shown for this controller
- if(isset($li3_perf['skip']['controller'])) {
- if(in_array($controller, $li3_perf['skip']['controller'])) {
- $skip = true;
- }
- }
-
- // Check to see if the toolbar should be shown for this action
- if(isset($li3_perf['skip']['action'])) {
- if(in_array($action, $li3_perf['skip']['action'])) {
- $skip = true;
- }
- }
- }
-
- if(isset($result->body[0]) && !$skip) {
- $result->body[0] = $toolbar . $result->body[0];
- }
+ $result->body[0] = $toolbar . $result->body[0];
}
return $result;
Please sign in to comment.
Something went wrong with that request. Please try again.