/** * Index action * * @return void */ public function indexAction() { // $dataRenderers = array( // ); // foreach ($this->debugger->getDebuggers() as $dataRenderer) { // $dataRenderers[$dataRenderer->getName()] = $dataRenderer; // } // $this->view->assign('dataRenderers', $dataRenderers); // if ($this->request->hasArgument('token')) { // $this->view->assign('token', $this->request->getArgument('token')); // \Debug\Toolbar\Service\DataStorage::load($this->request->getArgument('token')); // \Debug\Toolbar\Service\DataStorage::freeze(); // } if ($this->request->hasArgument('token')) { $this->view->assign('token', $this->request->getArgument('token')); \Debug\Toolbar\Service\DataStorage::load($this->request->getArgument('token')); \Debug\Toolbar\Service\DataStorage::freeze(); } $modules = \Debug\Toolbar\Service\Collector::getModules(); if ($this->request->hasArgument('module')) { foreach ($modules as $module) { if ($module->getName() == $this->request->getArgument('module')) { $currentModule = $module; break; } } } else { $currentModule = reset($modules); } $this->view->assign('currentModule', $currentModule); $this->view->assign('modules', $modules); }
/** * 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))); }
/** * Handles a HTTP request * * @return void */ public function handleRequest() { // Create the request very early so the Resource Management has a chance to grab it: $this->request = \TYPO3\Flow\Http\Request::createFromEnvironment(); $this->response = new \TYPO3\Flow\Http\Response(); $this->boot(); $this->resolveDependencies(); $this->request->injectSettings($this->settings); $this->addDebugToolbarRoutes(); $this->router->setRoutesConfiguration($this->routesConfiguration); $actionRequest = $this->router->route($this->request); $this->securityContext->setRequest($actionRequest); $this->dispatcher->dispatch($actionRequest, $this->response); $this->response->makeStandardsCompliant($this->request); \Debug\Toolbar\Service\DataStorage::add('Request:Requests', $actionRequest); \Debug\Toolbar\Service\DataStorage::add('Request:Responses', $this->response); \Debug\Toolbar\Toolbar\View::handleRedirects($this->request, $this->response); $this->emitAboutToRenderDebugToolbar(); \Debug\Toolbar\Service\DataStorage::set('Modules', \Debug\Toolbar\Service\Collector::getModules()); if ($actionRequest->getFormat() === 'html') { echo \Debug\Toolbar\Toolbar\View::attachToolbar($this->response->getContent()); } else { echo $this->response->getContent(); } $this->bootstrap->shutdown('Runtime'); $this->exit->__invoke(); \Debug\Toolbar\Service\DataStorage::save(); }
/** * 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)); }
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! */ public function preToolbarRendering() { $dispatcher = $this->objectManager->get('TYPO3\\Flow\\SignalSlot\\Dispatcher'); if (method_exists($dispatcher, 'getSignals')) { $classes = $this->objectManager->get('TYPO3\\Flow\\SignalSlot\\Dispatcher')->getSignals(); $classes = $this->sanitize($classes); \Debug\Toolbar\Service\Collector::getModule('Signals')->getToolbar()->addText('Signals')->addBadge(count($classes))->getPopup()->addPartial('Signals', array('classes' => $classes))->getPanel()->addPartial('Signals', array('classes' => $classes)); } }
/** * TODO: Document this Method! ( assignVariables ) */ public function preToolbarRendering() { $memoryUsage = memory_get_peak_usage(TRUE) / 1024 / 1024; $memoryUsage = number_format($memoryUsage, 1) . ' MB'; \Debug\Toolbar\Service\Collector::getModule('Environment')->getToolbar()->addIcon('info-sign')->addText($memoryUsage)->getPopup()->addTable(array('PHP Version' => PHP_VERSION, 'Flow Context' => $this->objectManager->getContext(), 'Flow Version' => FLOW_VERSION_BRANCH))->getPanel()->addTable(array('PHP Version' => PHP_VERSION, 'Flow Context' => $this->objectManager->getContext(), 'Flow Version' => FLOW_VERSION_BRANCH)); return; #$configurations = array(); #foreach ($configurations as $configurationName => $configurationConstant) { # $configuration = $this->configurationManager->getConfiguration($configurationConstant); # $configurations[$configurationName] = \Symfony\Component\Yaml\Yaml::dump($configuration, 10); #} #$configurations["Constants"] = \Symfony\Component\Yaml\Yaml::dump(get_defined_constants(), 10); #$this->view->assign('configurations', $configurations); }
public function preToolbarRendering() { $logDir = FLOW_PATH_DATA . 'Logs/'; $logFiles = scandir($logDir); $logs = array(); foreach ($logFiles as $logFile) { if (pathinfo($logFile, PATHINFO_EXTENSION) !== 'log') { continue; } $lines = file($logDir . '/' . $logFile); $lines = array_slice($lines, -200); foreach ($lines as $key => $line) { $loggingLevels = array(' DEBUG ' => ' <span class="muted">DEBUG</span> ', ' INFO ' => ' <span class="text-info">INFO</span> ', ' NOTICE ' => ' <span class="text-warning">NOTICE</span> ', ' WARNING ' => ' <span class="text-warning">WARNING</span> ', ' ERROR ' => ' <span class="text-error">ERROR</span> ', ' CRITICAL ' => ' <span class="text-error">CRITICAL</span> ', ' ALERT ' => ' <span class="text-error">ALERT</span> ', ' EMERGENCY ' => ' <span class="text-error">EMERGENCY</span> '); $lines[$key] = str_replace(array_keys($loggingLevels), array_values($loggingLevels), $line); } $logs[$logFile] = $lines; unset($lines); } \Debug\Toolbar\Service\Collector::getModule('Logging')->getToolbar()->addIcon('list-alt')->addText('Logging')->getPopup()->setClass('fullscreen')->addPartial('Logging', array('logs' => $logs))->getPanel()->addPartial('Logging', array('logs' => $logs)); }
public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap) { $bootstrap->registerRequestHandler(new \Debug\Toolbar\Http\RequestHandler($bootstrap)); if (!file_exists(FLOW_PATH_DATA . 'Logs/Debug')) { mkdir(FLOW_PATH_DATA . 'Logs/Debug'); } \Debug\Toolbar\Service\DataStorage::init(); $dispatcher = $bootstrap->getSignalSlotDispatcher(); \Debug\Toolbar\Service\Collector::setDispatcher($dispatcher); $dispatcher->connect('Debug\\Toolbar\\Http\\RequestHandler', 'aboutToRenderDebugToolbar', 'Debug\\Toolbar\\Debugger\\RequestDebugger', 'preToolbarRendering'); $dispatcher->connect('Debug\\Toolbar\\Http\\RequestHandler', 'aboutToRenderDebugToolbar', 'Debug\\Toolbar\\Debugger\\AopDebugger', 'preToolbarRendering'); $dispatcher->connect('Debug\\Toolbar\\Http\\RequestHandler', 'aboutToRenderDebugToolbar', 'Debug\\Toolbar\\Debugger\\EnvironmentDebugger', 'preToolbarRendering'); $dispatcher->connect('Debug\\Toolbar\\Http\\RequestHandler', 'aboutToRenderDebugToolbar', 'Debug\\Toolbar\\Debugger\\SecurityDebugger', 'preToolbarRendering'); $dispatcher->connect('Debug\\Toolbar\\Http\\RequestHandler', 'aboutToRenderDebugToolbar', 'Debug\\Toolbar\\Debugger\\SignalDebugger', 'preToolbarRendering'); $dispatcher->connect('Debug\\Toolbar\\Http\\RequestHandler', 'aboutToRenderDebugToolbar', 'Debug\\Toolbar\\Debugger\\SqlDebugger', 'preToolbarRendering'); // $dispatcher->connect( // 'Debug\Toolbar\Http\RequestHandler', 'aboutToRenderDebugToolbar', // 'Debug\Toolbar\Debugger\DumpDebugger', 'preToolbarRendering' // ); $dispatcher->connect('Debug\\Toolbar\\Http\\RequestHandler', 'aboutToRenderDebugToolbar', 'Debug\\Toolbar\\Debugger\\LoggingDebugger', 'preToolbarRendering'); $dispatcher->connect('TYPO3\\Flow\\Http\\Response', 'postProcessResponseContent', 'Debug\\Toolbar\\Toolbar\\View', 'receivePostProcessResponseContent'); $dispatcher->connect('TYPO3\\Flow\\Mvc\\ActionRequest', 'requestDispatched', 'Debug\\Toolbar\\Debugger\\RequestDebugger', 'collectRequests'); $dispatcher->connect('TYPO3\\Flow\\Aop\\Advice\\AbstractAdvice', 'adviceInvoked', 'Debug\\Toolbar\\Debugger\\AopDebugger', 'collectAdvices'); }
/** * TODO: Document this Method! ( render ) */ public function render() { \Debug\Toolbar\Service\DataStorage::save(); $this->view->assign('modules', \Debug\Toolbar\Service\Collector::getModules()); return $this->view->render(); }
/** * TODO: Document this Method! ( load ) */ public static function load($token) { $filename = FLOW_PATH_DATA . '/Logs/Debug/' . $token . '.debug'; $data = file_get_contents($filename); self::$container = @unserialize($data); \Debug\Toolbar\Service\Collector::setModules(self::get('Modules')); }
/** * Emits a signal before the toolbar gets rendered * * @return void * @Flow\Signal */ protected function emitAboutToRenderDebugToolbar() { \Debug\Toolbar\Service\Collector::getDispatcher()->dispatch(__CLASS__, 'aboutToRenderDebugToolbar', array()); }