Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationLatte
      • ApplicationTracy
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsLatte
      • Framework
      • HttpTracy
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • none
  • Tracy

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