/**
  * 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);
 }
Example #2
0
 /**
  * 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));
 }
Example #5
0
 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');
 }
Example #6
0
 /**
  * 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();
 }
Example #7
0
 /**
  * @return void
  */
 public function stopQuery()
 {
     $time = microtime() - $this->start;
     \Debug\Toolbar\Service\DataStorage::add('SqlLogger:Times', $time);
 }
 /**
  * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint
  * @Flow\Before("method(TYPO3\Flow\Http\RequestHandler->handleRequest())")
  * @return void
  */
 public function setStartTime(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint)
 {
     \Debug\Toolbar\Service\DataStorage::set('Runtime:Start', microtime());
 }
Example #9
0
 /**
  * TODO: Document this Method!
  */
 public function collectAdvices($adviceObject, $methodName, $joinPoint)
 {
     \Debug\Toolbar\Service\DataStorage::add('AOP:Advices', array('adviceClass' => get_class($adviceObject), 'adviceMethodName' => $methodName, 'joinPointClass' => $joinPoint->getClassName(), 'joinPointMethodName' => $joinPoint->getMethodName()));
 }
Example #10
0
 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);
 }
    /**
     * Formats and echoes the exception as XHTML.
     *
     * @param \Exception $exception The exception object
     * @return void
     */
    protected function echoExceptionWeb(\Exception $exception)
    {
        if (!headers_sent()) {
            header('HTTP/1.1 500 Internal Server Error');
        }
        $exceptionHeader = '';
        while (TRUE) {
            $pathPosition = strpos($exception->getFile(), 'Packages/');
            $filePathAndName = $pathPosition !== FALSE ? substr($exception->getFile(), $pathPosition) : $exception->getFile();
            $exceptionCodeNumber = $exception->getCode() > 0 ? '#' . $exception->getCode() . ': ' : '';
            $moreInformationLink = $exceptionCodeNumber != '' ? '(<a href="http://typo3.org/go/exception/' . $exception->getCode() . '">More information</a>)' : '';
            $createIssueLink = $this->getCreateIssueLink($exception);
            $exceptionHeader .= '
				<strong style="color: #BE0027;">' . $exceptionCodeNumber . htmlspecialchars($exception->getMessage()) . '</strong> ' . $moreInformationLink . '<br />
				<br />
				<span class="ExceptionProperty">' . get_class($exception) . '</span> thrown in file<br />
				<span class="ExceptionProperty">' . $filePathAndName . '</span> in line
				<span class="ExceptionProperty">' . $exception->getLine() . '</span>.<br />';
            if ($exception instanceof \TYPO3\Flow\Exception) {
                $exceptionHeader .= '<span class="ExceptionProperty">Reference code: ' . $exception->getReferenceCode() . '</span><br />';
            }
            if ($exception->getPrevious() === NULL) {
                $exceptionHeader .= '<br /><a href="' . $createIssueLink . '">Go to the FORGE issue tracker and report the issue</a> - <strong>if you think it is a bug!</strong><br />';
                break;
            } else {
                $exceptionHeader .= '<br /><div style="width: 100%; background-color: #515151; color: white; padding: 2px; margin: 0 0 6px 0;">Nested Exception</div>';
                $exception = $exception->getPrevious();
            }
        }
        $backtraceCode = \TYPO3\Flow\Error\Debugger::getBacktraceCode($exception->getTrace());
        echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
				"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
			<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
			<head>
				<title>Flow Exception</title>
				<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
			</head>
			<style>
				.ExceptionProperty {
					color: #101010;
				}
				pre {
					margin: 0;
					font-size: 11px;
					color: #515151;
					background-color: #D0D0D0;
					padding-left: 30px;
				}
			</style>
			<div style="
					position: absolute;
					left: 10px;
					background-color: #B9B9B9;
					outline: 1px solid #515151;
					color: #515151;
					font-family: Arial, Helvetica, sans-serif;
					font-size: 12px;
					margin: 10px;
					padding: 0;
				">
				<div style="width: 100%; background-color: #515151; color: white; padding: 2px; margin: 0 0 6px 0;">Uncaught Exception in Flow</div>
				<div style="width: 100%; padding: 2px; margin: 0 0 6px 0;">
					' . $exceptionHeader . '
					<br />
					' . $backtraceCode . '
				</div>
			</div>
		';
        $response = new \TYPO3\Flow\Http\Response();
        $response->setStatus(400);
        \Debug\Toolbar\Service\DataStorage::add('Request:Responses', $response);
        $this->emitAboutToRenderDebugToolbar();
        $toolbar = new \Debug\Toolbar\Toolbar\View();
        echo $toolbar->render();
    }