Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • 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

  • ContainerPanel
  • 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\DI\Diagnostics;
13: 
14: use Nette,
15:     Nette\DI\Container,
16:     Nette\Diagnostics\Helpers;
17: 
18: 
19: 
20: /**
21:  * Dependency injection container panel for Debugger Bar.
22:  *
23:  * @author     Patrik Votoček
24:  */
25: class ContainerPanel extends Nette\Object implements Nette\Diagnostics\IBarPanel
26: {
27:     /** @var Nette\DI\Container */
28:     private $container;
29: 
30: 
31: 
32:     public function __construct(Container $container)
33:     {
34:         $this->container = $container;
35:     }
36: 
37: 
38: 
39:     /**
40:      * Renders tab.
41:      * @return string
42:      */
43:     public function getTab()
44:     {
45:         ob_start();
46:         require __DIR__ . '/templates/ContainerPanel.tab.phtml';
47:         return ob_get_clean();
48:     }
49: 
50: 
51: 
52:     /**
53:      * Renders panel.
54:      * @return string
55:      */
56:     public function getPanel()
57:     {
58:         $services = $this->getContainerProperty('factories');
59:         $factories = array();
60:         foreach (Nette\Reflection\ClassType::from($this->container)->getMethods() as $method) {
61:             if (preg_match('#^create(Service)?(.+)$#', $method->getName(), $m)) {
62:                 $name = strtolower(substr($m[2], 0, 1)) . substr($m[2], 1);
63:                 if ($m[1]) {
64:                     $services[$name] = $method->getAnnotation('return');
65:                 } elseif ($method->isPublic()) {
66:                     $factories[substr_replace($name, 'create', strrpos("_$name", '_'), 0)] = $method->getAnnotation('return');
67:                 }
68:             }
69:         }
70:         ksort($services);
71:         ksort($factories);
72:         $container = $this->container;
73:         $registry = $this->getContainerProperty('registry');
74: 
75:         ob_start();
76:         require __DIR__ . '/templates/ContainerPanel.panel.phtml';
77:         return ob_get_clean();
78:     }
79: 
80: 
81: 
82:     private function getContainerProperty($name)
83:     {
84:         $prop = Nette\Reflection\ClassType::from('Nette\DI\Container')->getProperty($name);
85:         $prop->setAccessible(TRUE);
86:         return $prop->getValue($this->container);
87:     }
88: 
89: }
90: 
Nette Framework 2.0beta2 API API documentation generated by ApiGen 2.3.0