1 | <?php |
||
10 | class CDI implements IDI |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * Properties |
||
15 | * |
||
16 | */ |
||
17 | public $loaded = []; // Store all lazy loaded services, ready to be instantiated |
||
18 | public $active = []; // A service is instantiated into this array, once its accessed |
||
19 | |||
20 | |||
21 | |||
22 | /** |
||
23 | * Construct. |
||
24 | * |
||
25 | */ |
||
26 | public function __construct() |
||
30 | |||
31 | |||
32 | |||
33 | /** |
||
34 | * Return an arry with all loaded services names. |
||
35 | * |
||
36 | * @return void |
||
37 | */ |
||
38 | public function getServices() |
||
42 | |||
43 | |||
44 | |||
45 | /** |
||
46 | * Return an array with all loaded services that are controllers. |
||
47 | * |
||
48 | * @return void |
||
49 | */ |
||
50 | public function getControllers() |
||
59 | |||
60 | |||
61 | |||
62 | /** |
||
63 | * Return an arry with all active services names. |
||
64 | * |
||
65 | * @return void |
||
66 | */ |
||
67 | public function getActiveServices() |
||
71 | |||
72 | |||
73 | |||
74 | /** |
||
75 | * Set a service and connect it to a task which creates the object (lazy loading). |
||
76 | * |
||
77 | * @param string $service as a service label, naming this service. |
||
78 | * @param mixed $loader contains a pre-defined object, a string with classname or an |
||
79 | * callable which returns an instance of the service object. Its the way to |
||
80 | * actually load, insantiate, the serviceobject. |
||
81 | * @param boolean $singleton set if service is to act as singleton or not, default is false. |
||
82 | * |
||
83 | * @return nothing. |
||
|
|||
84 | */ |
||
85 | public function set($service, $loader, $singleton = false) |
||
90 | |||
91 | |||
92 | |||
93 | /** |
||
94 | * Set a singleton service and connect it to a task which creates the object (lazy loading). |
||
95 | * |
||
96 | * @param string $service as a service label, naming this service. |
||
97 | * @param mixed $loader contains a pre-defined object, a string with |
||
98 | * classname or an callable which returns an |
||
99 | * instance of the service object. Its the way |
||
100 | * to actually load, insantiate, the serviceobject. |
||
101 | * |
||
102 | * @return nothing. |
||
103 | */ |
||
104 | public function setShared($service, $loader) |
||
108 | |||
109 | |||
110 | |||
111 | /** |
||
112 | * Get an instance of the service object, managing singletons. |
||
113 | * |
||
114 | * @param string $service as a service label, naming this service. |
||
115 | * |
||
116 | * @return object as instance of the service object. |
||
117 | * @throws Exception when service accessed is not loaded. |
||
118 | */ |
||
119 | public function get($service) |
||
141 | |||
142 | |||
143 | |||
144 | /** |
||
145 | * Magic method to get and create services. |
||
146 | * When created it is also stored as a parameter of this object. |
||
147 | * |
||
148 | * @param string $service name of class property not existing. |
||
149 | * |
||
150 | * @return class as the service requested. |
||
151 | */ |
||
152 | public function __get($service) |
||
156 | |||
157 | |||
158 | |||
159 | /** |
||
160 | * Check if service exists by name. |
||
161 | * |
||
162 | * @param string $service as a service label, naming this service. |
||
163 | * |
||
164 | * @return boolean true if the service exists, otherwise false. |
||
165 | */ |
||
166 | public function has($service) |
||
172 | |||
173 | |||
174 | |||
175 | /** |
||
176 | * Magic method to get and create services. |
||
177 | * When created it is also stored as a parameter of this object. |
||
178 | * |
||
179 | * @param string $service name of class property not existing. |
||
180 | * @param array $arguments currently NOT USED. |
||
181 | * |
||
182 | * @return class as the service requested. |
||
183 | */ |
||
184 | public function __call($service, $arguments = []) |
||
188 | |||
189 | |||
190 | |||
191 | /** |
||
192 | * Lazy load a service object and create an instance of it. |
||
193 | * |
||
194 | * @param string $service as a service label, naming this service. |
||
195 | * |
||
196 | * @return object as instance of the service object. |
||
197 | * @throws Exception when service could not be loaded. |
||
198 | */ |
||
199 | protected function load($service) |
||
229 | } |
||
230 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.