1 | <?php |
||
8 | class Modules implements RepositoryInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var Application |
||
12 | */ |
||
13 | protected $app; |
||
14 | |||
15 | /** |
||
16 | * @var RepositoryInterface |
||
17 | */ |
||
18 | protected $repository; |
||
19 | |||
20 | /** |
||
21 | * Create a new Modules instance. |
||
22 | * |
||
23 | * @param Application $app |
||
24 | 1 | * @param RepositoryInterface $repository |
|
25 | */ |
||
26 | 1 | public function __construct(Application $app, RepositoryInterface $repository) |
|
31 | |||
32 | /** |
||
33 | * Register the module service provider file from all modules. |
||
34 | * |
||
35 | * @return mixed |
||
36 | */ |
||
37 | public function register() |
||
47 | |||
48 | /** |
||
49 | * Register the module service provider. |
||
50 | * |
||
51 | * @param string $properties |
||
52 | * |
||
53 | * @return string |
||
54 | * |
||
55 | * @throws \Caffeinated\Modules\Exception\FileMissingException |
||
56 | */ |
||
57 | protected function registerServiceProvider($properties) |
||
58 | { |
||
59 | $namespace = $this->resolveNamespace($properties); |
||
60 | $file = $this->repository->getPath()."/{$namespace}/Providers/{$namespace}ServiceProvider.php"; |
||
61 | $serviceProvider = $this->repository->getNamespace().'\\'.$namespace."\\Providers\\{$namespace}ServiceProvider"; |
||
62 | |||
63 | if (class_exists($serviceProvider)) { |
||
64 | $this->app->register($serviceProvider); |
||
65 | } |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Autoload custom module files. |
||
70 | * |
||
71 | * @param array $properties |
||
72 | */ |
||
73 | protected function autoloadFiles($properties) |
||
84 | |||
85 | public function optimize() |
||
89 | |||
90 | /** |
||
91 | * Get all modules. |
||
92 | * |
||
93 | * @return Collection |
||
94 | */ |
||
95 | public function all() |
||
99 | |||
100 | /** |
||
101 | * Get all module slugs. |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | public function slugs() |
||
109 | |||
110 | /** |
||
111 | * Get modules based on where clause. |
||
112 | * |
||
113 | * @param string $key |
||
114 | * @param mixed $value |
||
115 | * |
||
116 | * @return Collection |
||
117 | */ |
||
118 | public function where($key, $value) |
||
122 | |||
123 | /** |
||
124 | * Sort modules by given key in ascending order. |
||
125 | * |
||
126 | * @param string $key |
||
127 | * |
||
128 | * @return Collection |
||
129 | */ |
||
130 | public function sortBy($key) |
||
134 | |||
135 | /** |
||
136 | * Sort modules by given key in ascending order. |
||
137 | * |
||
138 | * @param string $key |
||
139 | * |
||
140 | * @return Collection |
||
141 | */ |
||
142 | public function sortByDesc($key) |
||
146 | |||
147 | /** |
||
148 | * Check if the given module exists. |
||
149 | * |
||
150 | * @param string $slug |
||
151 | * |
||
152 | * @return bool |
||
153 | */ |
||
154 | public function exists($slug) |
||
158 | |||
159 | /** |
||
160 | * Returns count of all modules. |
||
161 | * |
||
162 | * @return int |
||
163 | */ |
||
164 | public function count() |
||
168 | |||
169 | /** |
||
170 | * Get modules path. |
||
171 | * |
||
172 | * @return string |
||
173 | */ |
||
174 | public function getPath() |
||
178 | |||
179 | /** |
||
180 | * Set modules path in "RunTime" mode. |
||
181 | * |
||
182 | * @param string $path |
||
183 | * |
||
184 | * @return object $this |
||
185 | */ |
||
186 | public function setPath($path) |
||
190 | |||
191 | /** |
||
192 | * Get path for the specified module. |
||
193 | * |
||
194 | * @param string $slug |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | public function getModulePath($slug) |
||
202 | |||
203 | /** |
||
204 | * Get modules namespace. |
||
205 | * |
||
206 | * @return string |
||
207 | */ |
||
208 | public function getNamespace() |
||
212 | |||
213 | /** |
||
214 | * Get a module's properties. |
||
215 | * |
||
216 | * @param string $slug |
||
217 | * |
||
218 | * @return mixed |
||
219 | */ |
||
220 | public function getManifest($slug) |
||
224 | |||
225 | /** |
||
226 | * Get a module property value. |
||
227 | * |
||
228 | * @param string $property |
||
229 | * @param mixed $default |
||
230 | * |
||
231 | * @return mixed |
||
232 | */ |
||
233 | public function get($property, $default = null) |
||
237 | |||
238 | /** |
||
239 | * Set a module property value. |
||
240 | * |
||
241 | * @param string $property |
||
242 | * @param mixed $value |
||
243 | * |
||
244 | * @return bool |
||
245 | */ |
||
246 | public function set($property, $value) |
||
250 | |||
251 | /** |
||
252 | * Gets all enabled modules. |
||
253 | * |
||
254 | * @return array |
||
255 | */ |
||
256 | public function enabled() |
||
260 | |||
261 | /** |
||
262 | * Gets all disabled modules. |
||
263 | * |
||
264 | * @return array |
||
265 | */ |
||
266 | public function disabled() |
||
270 | |||
271 | /** |
||
272 | * Check if specified module is enabled. |
||
273 | * |
||
274 | * @param string $slug |
||
275 | * |
||
276 | * @return bool |
||
277 | */ |
||
278 | public function isEnabled($slug) |
||
282 | |||
283 | /** |
||
284 | * Check if specified module is disabled. |
||
285 | * |
||
286 | * @param string $slug |
||
287 | * |
||
288 | * @return bool |
||
289 | */ |
||
290 | public function isDisabled($slug) |
||
294 | |||
295 | /** |
||
296 | * Enables the specified module. |
||
297 | * |
||
298 | * @param string $slug |
||
299 | * |
||
300 | * @return bool |
||
301 | */ |
||
302 | public function enable($slug) |
||
306 | |||
307 | /** |
||
308 | * Disables the specified module. |
||
309 | * |
||
310 | * @param string $slug |
||
311 | * |
||
312 | * @return bool |
||
313 | */ |
||
314 | public function disable($slug) |
||
318 | |||
319 | /** |
||
320 | * Resolve the correct module namespace. |
||
321 | * |
||
322 | * @param array $properties |
||
323 | */ |
||
324 | public function resolveNamespace($properties) |
||
331 | } |
||
332 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.