daib17 /
forecast
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Configuration file for DI container. |
||
| 4 | */ |
||
| 5 | return [ |
||
| 6 | |||
| 7 | // Services to add to the container. |
||
| 8 | "services" => [ |
||
| 9 | "cache" => [ |
||
| 10 | "shared" => true, |
||
| 11 | "callback" => function () { |
||
| 12 | $cache = new \Anax\Cache\FileCache(); |
||
| 13 | |||
| 14 | // Load the configuration files |
||
| 15 | $cfg = $this->get("configuration"); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
| 16 | $config = $cfg->load("cache.php"); |
||
| 17 | $file = $config["file"] ?? null; |
||
| 18 | $config = $config["config"] ?? null; |
||
| 19 | |||
| 20 | $path = $config["basePath"] ?? null; |
||
| 21 | if (!$path || !is_dir($path) || !is_writable($path)) { |
||
| 22 | throw new Exception("Configuration file '$file': Cachedir '$path' is not a writable directory."); |
||
| 23 | } |
||
| 24 | $cache->setPath($path); |
||
| 25 | |||
| 26 | $timeToLive = $config["timeToLive"] ?? null; |
||
| 27 | if ($timeToLive) { |
||
| 28 | $cache->setTimeToLive($timeToLive); |
||
| 29 | } |
||
| 30 | |||
| 31 | return $cache; |
||
| 32 | } |
||
| 33 | ], |
||
| 34 | ], |
||
| 35 | ]; |
||
| 36 |