<?php
namespace Harmonizely;
use Doctrine\Common\EventSubscriber;
use Harmonizely\Calendar\CalDav\Provider\CalendarClientProviderInterface;
use Harmonizely\DependencyInjection\Compiler\CalDavClientProviderPass;
use Harmonizely\DependencyInjection\Compiler\CustomDomainPass;
use Harmonizely\Service\Panel\AccessVoters\Contract\IVoter;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel as BaseKernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
use Harmonizely\Service\SuperAdmin\Panel\AccessVoters\Contract\IVoter as SuperAdminIVoter;
class Kernel extends BaseKernel
{
use MicroKernelTrait;
const CONFIG_EXTS = '.{php,xml,yaml,yml}';
public function getCacheDir(): string
{
return dirname(__DIR__).'/var/cache/'.$this->environment;
}
public function getLogDir(): string
{
return dirname(__DIR__).'/var/log';
}
public function registerBundles()
{
$contents = require dirname(__DIR__).'/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)
{
$confDir = dirname(__DIR__).'/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');
$loader->load($confDir . '/{super_admin}/*' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{sbpay}/*' . self::CONFIG_EXTS, 'glob');
}
protected function configureRoutes(RouteCollectionBuilder $routes)
{
$confDir = dirname(__DIR__).'/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');
}
protected function build(ContainerBuilder $container): void
{
parent::build($container);
$container->registerForAutoconfiguration(IVoter::class)->addTag('hrm.acl.voter');
$container->registerForAutoconfiguration(SuperAdminIVoter::class)->addTag('hrm.acl.super_admin.voter');
$container->registerForAutoconfiguration(CalendarClientProviderInterface::class)
->addTag('hrm.caldav_client.provider');
$container->registerForAutoconfiguration(EventSubscriber::class)
->addTag('doctrine.event_subscriber');
$container->addCompilerPass(new CalDavClientProviderPass());
$container->addCompilerPass(new CustomDomainPass());
}
}