| Conditions | 2 |
| Paths | 1 |
| Total Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function register(Container $c): void |
||
| 17 | { |
||
| 18 | $c['view'] = static function ($c) { |
||
| 19 | // Configure Twig view for slim |
||
| 20 | $view = new Twig(); |
||
| 21 | |||
| 22 | $view->twigTemplateDirs = [ |
||
| 23 | $c['app.template_dir'], |
||
| 24 | ]; |
||
| 25 | $view->parserOptions = [ |
||
| 26 | 'charset' => 'utf-8', |
||
| 27 | 'cache' => $c['app.cache_dir'], |
||
| 28 | 'auto_reload' => true, |
||
| 29 | 'strict_variables' => false, |
||
| 30 | 'autoescape' => 'html', |
||
| 31 | ]; |
||
| 32 | |||
| 33 | // set global variables to templates |
||
| 34 | $view->appendData([ |
||
| 35 | 'date_format' => $c['config']['date.format'], |
||
| 36 | ]); |
||
| 37 | |||
| 38 | return $view; |
||
| 39 | }; |
||
| 40 | |||
| 41 | $c['app'] = static function ($c) { |
||
| 42 | if ($c['config']['timezone']) { |
||
| 43 | date_default_timezone_set($c['config']['timezone']); |
||
| 44 | } |
||
| 45 | |||
| 46 | $app = new App($c['config']); |
||
| 47 | |||
| 48 | $view = $c['view']; |
||
| 49 | $view->parserExtensions = [ |
||
| 50 | new TwigExtension($app), |
||
| 51 | ]; |
||
| 52 | $app->view($view); |
||
| 53 | |||
| 54 | return $app; |
||
| 55 | }; |
||
| 56 | } |
||
| 57 | } |
||
| 58 |