| Conditions | 3 |
| Paths | 1 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 25 | public function register() |
||
| 26 | { |
||
| 27 | $config = $this->getContainer()->get('config'); |
||
| 28 | $globals = [ |
||
| 29 | 'base_url' => $config['base_url'], |
||
| 30 | 'asset_url' => $config['base_url'] . '/assets', |
||
| 31 | 'env' => $config['environment'] |
||
| 32 | ]; |
||
| 33 | |||
| 34 | // Register the singleton with the container |
||
| 35 | $this->getContainer()->share('Twig_Environment', function () use ($globals, $config) { |
||
| 36 | $loader = new Twig_Loader_Filesystem(__DIR__ . '/../../template'); |
||
| 37 | $twig = new Twig_Environment($loader, [ |
||
| 38 | 'cache' => false, |
||
| 39 | 'debug' => $config['environment'] === 'development' ? true : false |
||
| 40 | ]); |
||
| 41 | |||
| 42 | // Add Globals |
||
| 43 | foreach ($globals as $key => $val) { |
||
| 44 | $twig->addGlobal($key, $val); |
||
| 45 | } |
||
| 46 | $twig->addExtension(new SlugifyExtension(Slugify::create(null, array('lowercase' => false)))); |
||
| 47 | |||
| 48 | return $twig; |
||
| 49 | }); |
||
| 50 | } |
||
| 51 | } |
||
| 52 |