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

Classes

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

Interfaces

  • IBarPanel
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Diagnostics;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * Debug Bar.
15:  *
16:  * @author     David Grudl
17:  */
18: class Bar extends Nette\Object
19: {
20:     /** @var array */
21:     private $panels = array();
22: 
23: 
24:     /**
25:      * Add custom panel.
26:      * @param  IBarPanel
27:      * @param  string
28:      * @return self
29:      */
30:     public function addPanel(IBarPanel $panel, $id = NULL)
31:     {
32:         if ($id === NULL) {
33:             $c = 0;
34:             do {
35:                 $id = get_class($panel) . ($c++ ? "-$c" : '');
36:             } while (isset($this->panels[$id]));
37:         }
38:         $this->panels[$id] = $panel;
39:         return $this;
40:     }
41: 
42: 
43:     /**
44:      * Renders debug bar.
45:      * @return void
46:      */
47:     public function render()
48:     {
49:         $obLevel = ob_get_level();
50:         $panels = array();
51:         foreach ($this->panels as $id => $panel) {
52:             try {
53:                 $panels[] = array(
54:                     'id' => preg_replace('#[^a-z0-9]+#i', '-', $id),
55:                     'tab' => $tab = (string) $panel->getTab(),
56:                     'panel' => $tab ? (string) $panel->getPanel() : NULL,
57:                 );
58:             } catch (\Exception $e) {
59:                 $panels[] = array(
60:                     'id' => "error-" . preg_replace('#[^a-z0-9]+#i', '-', $id),
61:                     'tab' => "Error in $id",
62:                     'panel' => '<h1>Error: ' . $id . '</h1><div class="nette-inner">' . nl2br(htmlSpecialChars($e)) . '</div>',
63:                 );
64:                 while (ob_get_level() > $obLevel) { // restore ob-level if broken
65:                     ob_end_clean();
66:                 }
67:             }
68:         }
69:         require __DIR__ . '/templates/bar.phtml';
70:     }
71: 
72: }
73: 
Nette 2.0 API documentation generated by ApiGen 2.8.0