moved twig globals to dynamic compiler pass (#264)

This commit is contained in:
Kevin Papst
2018-08-10 00:11:48 +02:00
committed by GitHub
parent 3dcd38eca7
commit c6e99b35d5
10 changed files with 128 additions and 20 deletions

View File

@@ -0,0 +1,33 @@
<?php
/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
* Dynamically adds twig globals.
*/
class TwigContextCompilerPass implements CompilerPassInterface
{
/**
* @param ContainerBuilder $container
* @throws \Exception
*/
public function process(ContainerBuilder $container)
{
$twig = $container->getDefinition('twig');
$theme = $container->getParameter('kimai.theme');
$durationOnly = $container->getParameter('kimai.timesheet.duration_only');
$twig->addMethodCall('addGlobal', ['kimai_context', $theme]);
$twig->addMethodCall('addGlobal', ['duration_only', $durationOnly]);
}
}