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

  • Bar
  • BlueScreen
  • Debugger
  • FireLogger
  • Helpers
  • Logger

Interfaces

  • IBarPanel
  • 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\Diagnostics;
13: 
14: use Nette;
15: 
16: 
17: 
18: /**
19:  * Debug Bar.
20:  *
21:  * @author     David Grudl
22:  */
23: class Bar extends Nette\Object
24: {
25:     /** @var array */
26:     private $panels = array();
27: 
28: 
29: 
30:     /**
31:      * Add custom panel.
32:      * @param  IBarPanel
33:      * @param  string
34:      * @return Bar  provides a fluent interface
35:      */
36:     public function addPanel(IBarPanel $panel, $id = NULL)
37:     {
38:         if ($id === NULL) {
39:             $c = 0;
40:             do {
41:                 $id = get_class($panel) . ($c++ ? "-$c" : '');
42:             } while (isset($this->panels[$id]));
43:         }
44:         $this->panels[$id] = $panel;
45:         return $this;
46:     }
47: 
48: 
49: 
50:     /**
51:      * Renders debug bar.
52:      * @return void
53:      */
54:     public function render()
55:     {
56:         $obLevel = ob_get_level();
57:         $panels = array();
58:         foreach ($this->panels as $id => $panel) {
59:             try {
60:                 $panels[] = array(
61:                     'id' => preg_replace('#[^a-z0-9]+#i', '-', $id),
62:                     'tab' => $tab = (string) $panel->getTab(),
63:                     'panel' => $tab ? (string) $panel->getPanel() : NULL,
64:                 );
65:             } catch (\Exception $e) {
66:                 $panels[] = array(
67:                     'id' => "error-$id",
68:                     'tab' => "Error: $id",
69:                     'panel' => nl2br(htmlSpecialChars((string) $e)),
70:                 );
71:                 while (ob_get_level() > $obLevel) { // restore ob-level if broken
72:                     ob_end_clean();
73:                 }
74:             }
75:         }
76:         require __DIR__ . '/templates/bar.phtml';
77:     }
78: 
79: }
80: 
Nette Framework 2.0.0 API API documentation generated by ApiGen 2.7.0