Packages

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

Classes

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