/** * TODO: Document this Method! */ public function preToolbarRendering() { $times = \Debug\Toolbar\Service\DataStorage::get('SqlLogger:Times'); if (!is_array($times)) { $times = array(); } $queries = \Debug\Toolbar\Service\DataStorage::get('SqlLogger:Queries'); $origins = \Debug\Toolbar\Service\DataStorage::get('SqlLogger:Origins'); $params = \Debug\Toolbar\Service\DataStorage::get('SqlLogger:Params'); $types = \Debug\Toolbar\Service\DataStorage::get('SqlLogger:Types'); $merged = array(); if (is_array($queries)) { foreach ($queries as $key => $value) { $origin = $origins[$key]; if (isset($origin['line'])) { $origin = 'Called from: ' . $origin['class'] . $origin['type'] . $origin['function'] . ' on line ' . $origin['line']; } else { $origin = ''; } $merged[$key] = array('query' => $value, 'time' => number_format($times[$key] * 1000, 2), 'origin' => $origin, 'params' => $params[$key], 'types' => $types[$key]); } } $merged = $this->formatQueries($merged); \Debug\Toolbar\Service\Collector::getModule('Sql')->getToolbar()->addIcon('hdd')->addBadge(count($queries))->getPopup()->addPartial('Sql/Statistic', array('time' => array_sum($times), 'queries' => $merged, 'queriesCount' => count($queries)))->getPanel()->addPartial('Sql/Queries', array('time' => array_sum($times), 'queries' => $merged, 'queriesCount' => count($queries))); }
public function preToolbarRendering() { $rawAdvices = (array) \Debug\Toolbar\Service\DataStorage::get('AOP:Advices'); $advices = array(); foreach ($rawAdvices as $key => $value) { if (stristr($value['adviceClass'], 'Debug\\Toolbar') && TRUE) { } else { $key = implode('.', $value); if (isset($advices[$key])) { $advices[$key]['counter']++; } else { $advices[$key] = $value; $advices[$key]['counter'] = 1; $reflectionClass = new \ReflectionClass($value['adviceClass']); $advices[$key]['classComment'] = $this->cleanupComment($reflectionClass->getDocComment()); $advices[$key]['methodComment'] = $this->cleanupComment($reflectionClass->getMethod($value['adviceMethodName'])->getDocComment()); } } } $table = ''; foreach ($advices as $advice) { $title = '<b>' . $advice['adviceClass'] . '->' . $advice['adviceClass'] . '</b> <br /> <small>Called ' . $advice['counter'] . ' times</small>'; $content = $advice['joinPointClass'] . '->' . $advice['joinPointMethodName']; $table .= '<table class="table table-striped table-bordered small-break signals">'; $table .= '<tr><th>' . $title . '</th></tr>'; $table .= '<tr><td class="indent-left">' . $content . '</td></tr>'; $table .= '</table>'; } \Debug\Toolbar\Service\Collector::getModule('AOP')->getToolbar()->addText('AOP')->addBadge(count($advices))->getPopup()->addHtml($table)->getPanel()->addHtml($table); }
/** * TODO: Document this Method! ( assignVariables ) */ public function preToolbarRendering() { $account = $this->context->getAccount(); $votes = array(); $privilege = array('PRIVILEGE_ABSTAIN', 'PRIVILEGE_GRANT', 'PRIVILEGE_DENY'); $roleVotes = \Debug\Toolbar\Service\DataStorage::get('Security:RoleVotes'); if (is_array($roleVotes)) { foreach ($roleVotes as $key => $value) { $vote = array('role' => (string) $value['role']); $vote['privilege'] = ''; if (is_array($value['privileges'])) { foreach ($value['privileges'] as $k => $p) { $vote['privilege'] = $privilege[$p]; } } $votes[$value['role'] . ':' . $vote['privilege']] = $vote; } } else { $roles = $this->context->getRoles(); foreach ($roles as $key => $value) { $vote = array('role' => (string) $value); $votes[] = $vote; } } \Debug\Toolbar\Service\Collector::getModule('Security')->getToolbar()->addIcon('user')->addText(is_object($account) ? $account->getAccountIdentifier() : 'Guest')->getPopup()->addPartial('Security', array('roles' => $this->context->getRoles(), 'account' => $this->context->getaccount(), 'votes' => $votes))->getPanel()->addPartial('Security', array('roles' => $this->context->getRoles(), 'account' => $this->context->getaccount(), 'votes' => $votes)); }
/** * TODO: Document this Method! ( handleRedirects ) */ public static function handleRedirects($request, $response) { $previousTokens = array(); if ($request->hasArgument('__previousDebugToken')) { $previousTokens = explode(',', $request->getArgument('__previousDebugToken')); \Debug\Toolbar\Service\DataStorage::set('Request:RedirectedRequest', implode(',', $previousTokens)); } if (intval($response->getStatus()) == 303) { $previousTokens[] = \Debug\Toolbar\Service\DataStorage::get('Environment:Token'); $location = $response->getHeaders()->get('Location'); $location .= stristr($location, '?') ? '&' : '?'; $location .= '__previousDebugToken=' . implode(',', $previousTokens); $response->getHeaders()->set('Location', $location); $response->setContent('<html><head><meta http-equiv="refresh" content="0;url=' . $location . '"/></head></html>'); } }
public function __construct($name) { $this->name = $name; $this->sections = array('toolbar' => new Section('toolbar'), 'popup' => new Section('popup'), 'panel' => new Section('panel')); $this->arguments = array('token' => \Debug\Toolbar\Service\DataStorage::get('Environment:Token'), 'module' => $name); }