Packages

  • 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

  • RoutingDebugger
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  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:  * @package Nette\Application\Diagnostics
 11:  */
 12: 
 13: 
 14: 
 15: /**
 16:  * Routing debugger for Debug Bar.
 17:  *
 18:  * @author     David Grudl
 19:  * @package Nette\Application\Diagnostics
 20:  */
 21: class RoutingDebugger extends Object implements IBarPanel
 22: {
 23:     /** @var IRouter */
 24:     private $router;
 25: 
 26:     /** @var IHttpRequest */
 27:     private $httpRequest;
 28: 
 29:     /** @var array */
 30:     private $routers = array();
 31: 
 32:     /** @var PresenterRequest */
 33:     private $request;
 34: 
 35: 
 36:     public static function initializePanel(Application $application)
 37:     {
 38:         Debugger::$blueScreen->addPanel(create_function('$e', 'extract($GLOBALS[0]['.array_push($GLOBALS[0], array('application'=>$application)).'-1], EXTR_REFS);
 39:             return $e ? NULL : array(
 40:                 \'tab\' => \'Nette Application\',
 41:                 \'panel\' => \'<h3>Requests</h3>\' . DebugHelpers::clickableDump($application->getRequests())
 42:                     . \'<h3>Presenter</h3>\' . DebugHelpers::clickableDump($application->getPresenter())
 43:             );
 44:         '));
 45:     }
 46: 
 47: 
 48:     public function __construct(IRouter $router, IHttpRequest $httpRequest)
 49:     {
 50:         $this->router = $router;
 51:         $this->httpRequest = $httpRequest;
 52:     }
 53: 
 54: 
 55:     /**
 56:      * Renders tab.
 57:      * @return string
 58:      */
 59:     public function getTab()
 60:     {
 61:         $this->analyse($this->router);
 62:         ob_start();
 63:         require dirname(__FILE__) . '/templates/RoutingPanel.tab.phtml';
 64:         return ob_get_clean();
 65:     }
 66: 
 67: 
 68:     /**
 69:      * Renders panel.
 70:      * @return string
 71:      */
 72:     public function getPanel()
 73:     {
 74:         ob_start();
 75:         require dirname(__FILE__) . '/templates/RoutingPanel.panel.phtml';
 76:         return ob_get_clean();
 77:     }
 78: 
 79: 
 80:     /**
 81:      * Analyses simple route.
 82:      * @param  IRouter
 83:      * @return void
 84:      */
 85:     private function analyse($router, $module = '')
 86:     {
 87:         if ($router instanceof RouteList) {
 88:             foreach ($router as $subRouter) {
 89:                 $this->analyse($subRouter, $module . $router->getModule());
 90:             }
 91:             return;
 92:         }
 93: 
 94:         $matched = 'no';
 95:         $request = $router->match($this->httpRequest);
 96:         if ($request) {
 97:             $request->setPresenterName($module . $request->getPresenterName());
 98:             $matched = 'may';
 99:             if (empty($this->request)) {
100:                 $this->request = $request;
101:                 $matched = 'yes';
102:             }
103:         }
104: 
105:         $this->routers[] = array(
106:             'matched' => $matched,
107:             'class' => get_class($router),
108:             'defaults' => $router instanceof Route || $router instanceof SimpleRouter ? $router->getDefaults() : array(),
109:             'mask' => $router instanceof Route ? $router->getMask() : NULL,
110:             'request' => $request,
111:             'module' => rtrim($module, ':')
112:         );
113:     }
114: 
115: }
116: 
Nette Framework 2.0.13 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.8.0