Namespaces

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

Classes

  • ContainerPanel
  • 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 (https://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\DI\Diagnostics;
 9: 
10: use Nette;
11: use Nette\DI\Container;
12: 
13: 
14: /**
15:  * Dependency injection container panel for Debugger Bar.
16:  *
17:  * @author     Patrik Votoček
18:  */
19: class ContainerPanel extends Nette\Object implements Nette\Diagnostics\IBarPanel
20: {
21:     /** @var Nette\DI\Container */
22:     private $container;
23: 
24: 
25:     public function __construct(Container $container)
26:     {
27:         $this->container = $container;
28:     }
29: 
30: 
31:     /**
32:      * Renders tab.
33:      * @return string
34:      */
35:     public function getTab()
36:     {
37:         ob_start();
38:         require __DIR__ . '/templates/ContainerPanel.tab.phtml';
39:         return ob_get_clean();
40:     }
41: 
42: 
43:     /**
44:      * Renders panel.
45:      * @return string
46:      */
47:     public function getPanel()
48:     {
49:         $services = array();
50:         foreach (Nette\Reflection\ClassType::from($this->container)->getMethods() as $method) {
51:             if (preg_match('#^createService_*(.+)\z#', $method->getName(), $m)) {
52:                 $services[str_replace('__', '.', strtolower(substr($m[1], 0, 1)) . substr($m[1], 1))] = $method->getAnnotation('return');
53:             }
54:         }
55:         ksort($services);
56:         $container = $this->container;
57:         $registry = $this->getContainerProperty('registry');
58:         $tags = array();
59:         $meta = $this->getContainerProperty('meta');
60:         if (isset($meta[Container::TAGS])) {
61:             foreach ($meta[Container::TAGS] as $tag => $tmp) {
62:                 foreach ($tmp as $service => $val) {
63:                     $tags[$service][$tag] = $val;
64:                 }
65:             }
66:         }
67: 
68:         ob_start();
69:         require __DIR__ . '/templates/ContainerPanel.panel.phtml';
70:         return ob_get_clean();
71:     }
72: 
73: 
74:     private function getContainerProperty($name)
75:     {
76:         $prop = Nette\Reflection\ClassType::from('Nette\DI\Container')->getProperty($name);
77:         $prop->setAccessible(TRUE);
78:         return $prop->getValue($this->container);
79:     }
80: 
81: }
82: 
Nette 2.1 API documentation generated by ApiGen 2.8.0