Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • None
  • PHP

Classes

  • RoutingPanel
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://nette.org)
  5:  *
  6:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
  7:  *
  8:  * For the full copyright and license information, please view
  9:  * the file license.txt that was distributed with this source code.
 10:  */
 11: 
 12: namespace Nette\Application\Diagnostics;
 13: 
 14: use Nette,
 15:     Nette\Application\Routers,
 16:     Nette\Application\UI\Presenter, // templates
 17:     Nette\Diagnostics\Debugger;
 18: 
 19: 
 20: 
 21: /**
 22:  * Routing debugger for Debug Bar.
 23:  *
 24:  * @author     David Grudl
 25:  */
 26: class RoutingPanel extends Nette\Object implements Nette\Diagnostics\IBarPanel
 27: {
 28:     /** @var Nette\Application\IRouter */
 29:     private $router;
 30: 
 31:     /** @var Nette\Http\IRequest */
 32:     private $httpRequest;
 33: 
 34:     /** @var array */
 35:     private $routers = array();
 36: 
 37:     /** @var Nette\Application\Request */
 38:     private $request;
 39: 
 40: 
 41: 
 42:     public static function initializePanel(Nette\Application\Application $application)
 43:     {
 44:         Debugger::$blueScreen->addPanel(function($e) use ($application) {
 45:             return $e ? NULL : array(
 46:                 'tab' => 'Nette Application',
 47:                 'panel' => '<h3>Requests</h3>' . Nette\Diagnostics\Helpers::clickableDump($application->getRequests())
 48:                     . '<h3>Presenter</h3>' . Nette\Diagnostics\Helpers::clickableDump($application->getPresenter())
 49:             );
 50:         });
 51:     }
 52: 
 53: 
 54: 
 55:     public function __construct(Nette\Application\IRouter $router, Nette\Http\IRequest $httpRequest)
 56:     {
 57:         $this->router = $router;
 58:         $this->httpRequest = $httpRequest;
 59:     }
 60: 
 61: 
 62: 
 63:     /**
 64:      * Renders tab.
 65:      * @return string
 66:      */
 67:     public function getTab()
 68:     {
 69:         $this->analyse($this->router);
 70:         ob_start();
 71:         require __DIR__ . '/templates/RoutingPanel.tab.phtml';
 72:         return ob_get_clean();
 73:     }
 74: 
 75: 
 76: 
 77:     /**
 78:      * Renders panel.
 79:      * @return string
 80:      */
 81:     public function getPanel()
 82:     {
 83:         ob_start();
 84:         require __DIR__ . '/templates/RoutingPanel.panel.phtml';
 85:         return ob_get_clean();
 86:     }
 87: 
 88: 
 89: 
 90:     /**
 91:      * Analyses simple route.
 92:      * @param  Nette\Application\IRouter
 93:      * @return void
 94:      */
 95:     private function analyse($router, $module = '')
 96:     {
 97:         if ($router instanceof Routers\RouteList) {
 98:             foreach ($router as $subRouter) {
 99:                 $this->analyse($subRouter, $module . $router->getModule());
100:             }
101:             return;
102:         }
103: 
104:         $matched = 'no';
105:         $request = $router->match($this->httpRequest);
106:         if ($request) {
107:             $request->setPresenterName($module . $request->getPresenterName());
108:             $matched = 'may';
109:             if (empty($this->request)) {
110:                 $this->request = $request;
111:                 $matched = 'yes';
112:             }
113:         }
114: 
115:         $this->routers[] = array(
116:             'matched' => $matched,
117:             'class' => get_class($router),
118:             'defaults' => $router instanceof Routers\Route || $router instanceof Routers\SimpleRouter ? $router->getDefaults() : array(),
119:             'mask' => $router instanceof Routers\Route ? $router->getMask() : NULL,
120:             'request' => $request,
121:             'module' => rtrim($module, ':')
122:         );
123:     }
124: 
125: }
126: 
Nette Framework 2.0.3 API API documentation generated by ApiGen 2.7.0