1 | <?php |
||
2 | /** |
||
3 | * Create a collection of views. |
||
4 | */ |
||
5 | return [ |
||
6 | "services" => [ |
||
7 | "view" => [ |
||
8 | "active" => false, |
||
9 | "shared" => true, |
||
10 | "callback" => function () { |
||
11 | $view = new \Anax\View\ViewCollection(); |
||
12 | $view->setDI($this); |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
![]() |
|||
13 | |||
14 | // Load the configuration files |
||
15 | $cfg = $this->get("configuration"); |
||
16 | $config = $cfg->load("view.php"); |
||
17 | $file = $config["file"] ?? null; |
||
18 | |||
19 | $paths = $config["config"]["paths"] ?? null; |
||
20 | if (!$paths) { |
||
21 | throw new Exception("Configuration file '$file' has no key 'paths', its needed."); |
||
22 | } |
||
23 | $view->setPaths($paths); |
||
24 | |||
25 | $suffix = $config["config"]["suffix"] ?? null; |
||
26 | if ($suffix) { |
||
27 | $view->setSuffix($suffix); |
||
28 | } |
||
29 | |||
30 | return $view; |
||
31 | } |
||
32 | ], |
||
33 | ], |
||
34 | ]; |
||
35 |