* added unit tests and documentation #112 * fixed DashboardController * added CONTRIBUTION guidelines * fixed license year
82 lines
2.9 KiB
PHP
82 lines
2.9 KiB
PHP
<?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;
|
|
|
|
use App\DependencyInjection\AppExtension;
|
|
use App\DependencyInjection\Compiler\DoctrineCompilerPass;
|
|
use App\Timesheet\CalculatorInterface;
|
|
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
|
|
use Symfony\Component\Config\Loader\LoaderInterface;
|
|
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
|
|
use Symfony\Component\Routing\RouteCollectionBuilder;
|
|
|
|
class Kernel extends BaseKernel
|
|
{
|
|
use MicroKernelTrait;
|
|
|
|
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
|
|
|
|
public function getCacheDir()
|
|
{
|
|
return $this->getProjectDir().'/var/cache/'.$this->environment;
|
|
}
|
|
|
|
public function getLogDir()
|
|
{
|
|
return $this->getProjectDir().'/var/log';
|
|
}
|
|
|
|
protected function build(ContainerBuilder $container)
|
|
{
|
|
$container->registerForAutoconfiguration(CalculatorInterface::class)->addTag('timesheet.calculator');
|
|
}
|
|
|
|
public function registerBundles()
|
|
{
|
|
$contents = require $this->getProjectDir().'/config/bundles.php';
|
|
foreach ($contents as $class => $envs) {
|
|
if (isset($envs['all']) || isset($envs[$this->environment])) {
|
|
yield new $class();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader)
|
|
{
|
|
$container->registerExtension(new AppExtension());
|
|
|
|
$container->setParameter('container.autowiring.strict_mode', true);
|
|
$container->setParameter('container.dumper.inline_class_loader', true);
|
|
$confDir = $this->getProjectDir().'/config';
|
|
$loader->load($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob');
|
|
if (is_dir($confDir.'/packages/'.$this->environment)) {
|
|
$loader->load($confDir.'/packages/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob');
|
|
}
|
|
$loader->load($confDir.'/services'.self::CONFIG_EXTS, 'glob');
|
|
$loader->load($confDir.'/services_'.$this->environment.self::CONFIG_EXTS, 'glob');
|
|
|
|
$container->addCompilerPass(new DoctrineCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1000);
|
|
}
|
|
|
|
protected function configureRoutes(RouteCollectionBuilder $routes)
|
|
{
|
|
$confDir = $this->getProjectDir().'/config';
|
|
if (is_dir($confDir.'/routes/')) {
|
|
$routes->import($confDir.'/routes/*'.self::CONFIG_EXTS, '/', 'glob');
|
|
}
|
|
if (is_dir($confDir.'/routes/'.$this->environment)) {
|
|
$routes->import($confDir.'/routes/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob');
|
|
}
|
|
$routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob');
|
|
}
|
|
}
|