These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Configuration file for DI container. |
||
4 | */ |
||
5 | return [ |
||
6 | |||
7 | // Services to add to the container. |
||
8 | "services" => [ |
||
9 | "router" => [ |
||
10 | "shared" => true, |
||
11 | "callback" => function () { |
||
12 | $router = new \Anax\Route\Router(); |
||
13 | $router->setDI($this); |
||
14 | |||
15 | // Load the configuration files |
||
16 | $cfg = $this->get("configuration"); |
||
17 | $config = $cfg->load("router"); |
||
18 | echo "ROUTER CONFIG"; |
||
19 | var_dump($config); |
||
0 ignored issues
–
show
Security
Debugging Code
introduced
by
Loading history...
|
|||
20 | |||
21 | // Add routes from configuration file |
||
22 | $file = null; |
||
23 | try { |
||
24 | $file = $config["file"]; |
||
25 | $router->addRoutes($config["config"] ?? []); |
||
26 | foreach ($config["items"] as $routes) { |
||
27 | $file = $routes["file"]; |
||
28 | $router->addRoutes($routes["config"]); |
||
29 | } |
||
30 | } catch (Exception $e) { |
||
31 | throw new Exception( |
||
32 | $e->getMessage() |
||
33 | . t( |
||
34 | " Configuration file: '@file'", |
||
35 | ["@file" => $file] |
||
36 | ) |
||
37 | ); |
||
38 | } |
||
39 | |||
40 | // Set DEVELOPMENT/PRODUCTION mode, if defined |
||
41 | if (isset($config["mode"])) { |
||
42 | $router->setMode($config["mode"]); |
||
43 | } else if (defined("ANAX_PRODUCTION")) { |
||
44 | $router->setMode(\Anax\Route\Router::PRODUCTION); |
||
45 | } |
||
46 | |||
47 | return $router; |
||
48 | } |
||
49 | ], |
||
50 | ], |
||
51 | ]; |
||
52 |