Issues (69)

config/di/page.php (1 issue)

1
<?php
2
/**
3
 * Configuration file for DI container.
4
 */
5
return [
6
7
    // Services to add to the container.
8
    "services" => [
9
        "page" => [
10
            "shared" => true,
11
            "callback" => function () {
12
                $page = new \Anax\Page\Page();
13
                $page->setDI($this);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
14
15
                // Load the configuration files
16
                $cfg = $this->get("configuration");
17
                $config = $cfg->load("page.php");
18
                $file = $config["file"] ?? null;
19
20
                // Add all views from configuration
21
                $views = $config["config"]["views"] ?? [];
22
                foreach ($views as $view) {
23
                    $page->add($view);
24
                }
25
26
                $layout = $config["config"]["layout"] ?? null;
27
                if (!$layout) {
28
                    throw new Exception("Missing configuration for layout in file '$file', its needed.");
29
                }
30
                $page->addLayout($layout);
31
32
                return $page;
33
            }
34
        ],
35
    ],
36
];
37