4
* This file is part of the Nette Framework (http://nette.org)
6
* Copyright (c) 2004 David Grudl (http://davidgrudl.com)
8
* For the full copyright and license information, please view
9
* the file license.txt that was distributed with this source code.
12
namespace Nette\Application\Diagnostics;
15
Nette\Application\Routers,
16
Nette\Application\UI\Presenter, // used in templates
17
Nette\Diagnostics\Dumper;
21
* Routing debugger for Debug Bar.
25
class RoutingPanel extends Nette\Object implements Nette\Diagnostics\IBarPanel
27
/** @var Nette\Application\IRouter */
30
/** @var Nette\Http\IRequest */
34
private $routers = array();
36
/** @var Nette\Application\Request */
40
public static function initializePanel(Nette\Application\Application $application)
42
Nette\Diagnostics\Debugger::getBlueScreen()->addPanel(function($e) use ($application) {
43
return $e ? NULL : array(
44
'tab' => 'Nette Application',
45
'panel' => '<h3>Requests</h3>' . Dumper::toHtml($application->getRequests())
46
. '<h3>Presenter</h3>' . Dumper::toHtml($application->getPresenter())
52
public function __construct(Nette\Application\IRouter $router, Nette\Http\IRequest $httpRequest)
54
$this->router = $router;
55
$this->httpRequest = $httpRequest;
63
public function getTab()
65
$this->analyse($this->router);
67
require __DIR__ . '/templates/RoutingPanel.tab.phtml';
68
return ob_get_clean();
76
public function getPanel()
79
require __DIR__ . '/templates/RoutingPanel.panel.phtml';
80
return ob_get_clean();
85
* Analyses simple route.
86
* @param Nette\Application\IRouter
89
private function analyse($router, $module = '')
91
if ($router instanceof Routers\RouteList) {
92
foreach ($router as $subRouter) {
93
$this->analyse($subRouter, $module . $router->getModule());
99
$request = $router->match($this->httpRequest);
101
$request->setPresenterName($module . $request->getPresenterName());
103
if (empty($this->request)) {
104
$this->request = $request;
109
$this->routers[] = array(
110
'matched' => $matched,
111
'class' => get_class($router),
112
'defaults' => $router instanceof Routers\Route || $router instanceof Routers\SimpleRouter ? $router->getDefaults() : array(),
113
'mask' => $router instanceof Routers\Route ? $router->getMask() : NULL,
114
'request' => $request,
115
'module' => rtrim($module, ':')