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 arry with all active services names. |
||
47 | * |
||
48 | * @return void |
||
49 | */ |
||
50 | public function getActiveServices() |
||
54 | |||
55 | |||
56 | |||
57 | /** |
||
58 | * Set a service and connect it to a task which creates the object (lazy loading). |
||
59 | * |
||
60 | * @param string $service as a service label, naming this service. |
||
61 | * @param mixed $loader contains a pre-defined object, a string with classname or an |
||
62 | * callable which returns an instance of the service object. Its the way to |
||
63 | * actually load, insantiate, the serviceobject. |
||
64 | * @param boolean $singleton set if service is to act as singleton or not, default is false. |
||
65 | * |
||
66 | * @return nothing. |
||
|
|||
67 | */ |
||
68 | public function set($service, $loader, $singleton = false) |
||
73 | |||
74 | |||
75 | |||
76 | /** |
||
77 | * Set a singleton service and connect it to a task which creates the object (lazy loading). |
||
78 | * |
||
79 | * @param string $service as a service label, naming this service. |
||
80 | * @param mixed $loader contains a pre-defined object, a string with classname or an |
||
81 | * callable which returns an instance of the service object. Its the way to |
||
82 | * actually load, insantiate, the serviceobject. |
||
83 | * |
||
84 | * @return nothing. |
||
85 | */ |
||
86 | public function setShared($service, $loader) |
||
90 | |||
91 | |||
92 | |||
93 | /** |
||
94 | * Get an instance of the service object, managing singletons. |
||
95 | * |
||
96 | * @param string $service as a service label, naming this service. |
||
97 | * |
||
98 | * @return object as instance of the service object. |
||
99 | * @throws Exception when service accessed is not loaded. |
||
100 | */ |
||
101 | public function get($service) |
||
117 | |||
118 | |||
119 | |||
120 | /** |
||
121 | * Magic method to get and create services. |
||
122 | * When created it is also stored as a parameter of this object. |
||
123 | * |
||
124 | * @param string $service name of class property not existing. |
||
125 | * |
||
126 | * @return class as the service requested. |
||
127 | */ |
||
128 | public function __get($service) |
||
132 | |||
133 | |||
134 | |||
135 | /** |
||
136 | * Check if service exists by name. |
||
137 | * |
||
138 | * @param string $service as a service label, naming this service. |
||
139 | * |
||
140 | * @return boolean true if the service exists, otherwise false. |
||
141 | */ |
||
142 | public function has($service) |
||
148 | |||
149 | |||
150 | |||
151 | /** |
||
152 | * Magic method to get and create services. |
||
153 | * When created it is also stored as a parameter of this object. |
||
154 | * |
||
155 | * @param string $service name of class property not existing. |
||
156 | * @param array $arguments currently NOT USED. |
||
157 | * |
||
158 | * @return class as the service requested. |
||
159 | */ |
||
160 | public function __call($service, $arguments = []) |
||
164 | |||
165 | |||
166 | |||
167 | /** |
||
168 | * Lazy load a service object and create an instance of it. |
||
169 | * |
||
170 | * @param string $service as a service label, naming this service. |
||
171 | * |
||
172 | * @return object as instance of the service object. |
||
173 | * @throws Exception when service could not be loaded. |
||
174 | */ |
||
175 | protected function load($service) |
||
205 | } |
||
206 |
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.