1 | <?php |
||
29 | class Container implements ContainerInterface, ReferenceInterface, ConfigAwareInterface |
||
30 | { |
||
31 | use ContainerTrait; |
||
32 | use StaticAccessTrait; |
||
33 | |||
34 | /** |
||
35 | * Constructor |
||
36 | * |
||
37 | * $config for config & reference lookup |
||
38 | * $delegator for object lookup. If NULL will use $this |
||
39 | * |
||
40 | * @param Config $config |
||
41 | * @param ContainerInterface $delegator |
||
42 | */ |
||
43 | public function __construct( |
||
56 | |||
57 | /** |
||
58 | * |
||
59 | * ```php |
||
60 | * // get the cache object |
||
61 | * $cache = $container->get('cache'); |
||
62 | * |
||
63 | * // always get a NEW cache object |
||
64 | * $cacheNew = $container->get('cache@'); |
||
65 | * |
||
66 | * // get an object shared in SESSION scope |
||
67 | * $sessCache = $container->get('cache@SESSION'); |
||
68 | * |
||
69 | * // get object (created already by definition) by classname/interface name |
||
70 | * // useful for dependency injection |
||
71 | * $cache = $container->get(CacheInterface::class); |
||
72 | * |
||
73 | * // get a NEW object by classname |
||
74 | * // useful for creating object and utilize 'di.before' & 'di.after' |
||
75 | * $obj = $container->get(myClass::class); |
||
76 | * ``` |
||
77 | * |
||
78 | * {@inheritDoc} |
||
79 | */ |
||
80 | public function get($id): object |
||
92 | |||
93 | /** |
||
94 | * {@inheritDoc} |
||
95 | */ |
||
96 | public function has($id): bool |
||
100 | |||
101 | /** |
||
102 | * Reload & resolve all service definitions |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | protected function initContainer(): void |
||
123 | |||
124 | /** |
||
125 | * Resolve defined ids |
||
126 | * |
||
127 | * @param array $ids |
||
128 | * @param bool $autoClass |
||
129 | * @return void |
||
130 | */ |
||
131 | protected function resolveAllIds(array &$ids, bool $autoClass = FALSE): void |
||
149 | |||
150 | protected function autoResolve(): void |
||
170 | } |