Packages

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

Classes

  • NRoutingDebugger
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: 
  3: /**
  4:  * This file is part of the Nette Framework (http://nette.org)
  5:  *
  6:  * Copyright (c) 2004, 2011 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 NRoutingDebugger extends NObject 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 NPresenterRequest */
 33:     private $request;
 34: 
 35: 
 36: 
 37:     public static function initialize(NApplication $application, IHttpRequest $httpRequest)
 38:     {
 39:         NDebugger::$bar->addPanel(new self($application->getRouter(), $httpRequest));
 40:         NDebugger::$blueScreen->addPanel(create_function('$e', 'extract(NCFix::$vars['.NCFix::uses(array('application'=>$application)).'], EXTR_REFS);
 41:             if ($e === NULL) {
 42:                 return array(
 43:                     \'tab\' => \'Nette Application\',
 44:                     \'panel\' => \'<h3>Requests</h3>\' . NDebugHelpers::clickableDump($application->getRequests())
 45:                         . \'<h3>Presenter</h3>\' . NDebugHelpers::clickableDump($application->getPresenter())
 46:                 );
 47:             }
 48:         '));
 49:     }
 50: 
 51: 
 52: 
 53:     public function __construct(IRouter $router, IHttpRequest $httpRequest)
 54:     {
 55:         $this->router = $router;
 56:         $this->httpRequest = $httpRequest;
 57:     }
 58: 
 59: 
 60: 
 61:     /**
 62:      * Renders tab.
 63:      * @return string
 64:      */
 65:     public function getTab()
 66:     {
 67:         $this->analyse($this->router);
 68:         ob_start();
 69:         require dirname(__FILE__) . '/templates/RoutingPanel.tab.phtml';
 70:         return ob_get_clean();
 71:     }
 72: 
 73: 
 74: 
 75:     /**
 76:      * Renders panel.
 77:      * @return string
 78:      */
 79:     public function getPanel()
 80:     {
 81:         ob_start();
 82:         require dirname(__FILE__) . '/templates/RoutingPanel.panel.phtml';
 83:         return ob_get_clean();
 84:     }
 85: 
 86: 
 87: 
 88:     /**
 89:      * Analyses simple route.
 90:      * @param  IRouter
 91:      * @return void
 92:      */
 93:     private function analyse($router)
 94:     {
 95:         if ($router instanceof NRouteList) {
 96:             foreach ($router as $subRouter) {
 97:                 $this->analyse($subRouter);
 98:             }
 99:             return;
100:         }
101: 
102:         $request = $router->match($this->httpRequest);
103:         $matched = $request === NULL ? 'no' : 'may';
104:         if ($request !== NULL && empty($this->request)) {
105:             $this->request = $request;
106:             $matched = 'yes';
107:         }
108: 
109:         $this->routers[] = array(
110:             'matched' => $matched,
111:             'class' => get_class($router),
112:             'defaults' => $router instanceof NRoute || $router instanceof NSimpleRouter ? $router->getDefaults() : array(),
113:             'mask' => $router instanceof NRoute ? $router->getMask() : NULL,
114:             'request' => $request,
115:         );
116:     }
117: 
118: }
119: 
Nette Framework 2.0beta1 (for PHP 5.2) API API documentation generated by ApiGen 2.3.0