<?php

namespace AutoAdmin\Bundle\Tests\Functional;

use AutoAdmin\Bundle\AutoAdminBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Knp\Bundle\MenuBundle\KnpMenuBundle;
use Liip\ImagineBundle\LiipImagineBundle;
use Setono\BotDetectionBundle\SetonoBotDetectionBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\SecurityBundle\SecurityBundle;
use Symfony\Bundle\TwigBundle\TwigBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\RequestContext;
use Symfony\WebpackEncoreBundle\WebpackEncoreBundle;

class TestKernel extends Kernel
{
    public function registerBundles(): iterable
    {
        return [
            new FrameworkBundle(),
            new DoctrineBundle(),
            new TwigBundle(),
            new LiipImagineBundle(),
            new SetonoBotDetectionBundle(),
            new SecurityBundle(),
            new WebpackEncoreBundle(),
            new KnpMenuBundle(),
            new AutoAdminBundle(),
        ];
    }

    public function registerContainerConfiguration(LoaderInterface $loader): void
    {
        $loader->load(__DIR__.'/config/config.yml');

        $loader->load(function (ContainerBuilder $container) {
            if (!$container->has('router.request_context')) {
                $container->register('router.request_context', RequestContext::class);
            }
        });

    }

    public function getCacheDir(): string
    {
        return 'var/cache';
    }

    public function getLogDir(): string
    {
        return 'var/logs';
    }

    public function getProjectDir(): string
    {
        return __DIR__.'/../Functional/';
    }
}
