1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13:
14:
15: 16: 17: 18: 19: 20:
21: class ContainerPanel extends Object implements IBarPanel
22: {
23:
24: private $container;
25:
26:
27:
28: public function __construct(DIContainer $container)
29: {
30: $this->container = $container;
31: }
32:
33:
34:
35: 36: 37: 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: 50: 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: