src/Kernel.php line 60

Open in your IDE?
  1. <?php
  2. namespace Harmonizely;
  3. use Doctrine\Common\EventSubscriber;
  4. use Harmonizely\Calendar\CalDav\Provider\CalendarClientProviderInterface;
  5. use Harmonizely\DependencyInjection\Compiler\CalDavClientProviderPass;
  6. use Harmonizely\DependencyInjection\Compiler\CustomDomainPass;
  7. use Harmonizely\Service\Panel\AccessVoters\Contract\IVoter;
  8. use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
  9. use Symfony\Component\Config\Loader\LoaderInterface;
  10. use Symfony\Component\DependencyInjection\ContainerBuilder;
  11. use Symfony\Component\HttpKernel\Kernel as BaseKernel;
  12. use Symfony\Component\Routing\RouteCollectionBuilder;
  13. use Harmonizely\Service\SuperAdmin\Panel\AccessVoters\Contract\IVoter as SuperAdminIVoter;
  14. class Kernel extends BaseKernel
  15. {
  16.     use MicroKernelTrait;
  17.     const CONFIG_EXTS '.{php,xml,yaml,yml}';
  18.     public function getCacheDir(): string
  19.     {
  20.         return dirname(__DIR__).'/var/cache/'.$this->environment;
  21.     }
  22.     public function getLogDir(): string
  23.     {
  24.         return dirname(__DIR__).'/var/log';
  25.     }
  26.     public function registerBundles()
  27.     {
  28.         $contents = require dirname(__DIR__).'/config/bundles.php';
  29.         foreach ($contents as $class => $envs) {
  30.             if (isset($envs['all']) || isset($envs[$this->environment])) {
  31.                 yield new $class();
  32.             }
  33.         }
  34.     }
  35.     protected function configureContainer(ContainerBuilder $containerLoaderInterface $loader)
  36.     {
  37.         $confDir dirname(__DIR__).'/config';
  38.         $loader->load($confDir.'/packages/*'.self::CONFIG_EXTS'glob');
  39.         if (is_dir($confDir.'/packages/'.$this->environment)) {
  40.             $loader->load($confDir.'/packages/'.$this->environment.'/**/*'.self::CONFIG_EXTS'glob');
  41.         }
  42.         $loader->load($confDir.'/services'.self::CONFIG_EXTS'glob');
  43.         $loader->load($confDir.'/services_'.$this->environment.self::CONFIG_EXTS'glob');
  44.         $loader->load($confDir '/{super_admin}/*' self::CONFIG_EXTS'glob');
  45.         $loader->load($confDir '/{sbpay}/*' self::CONFIG_EXTS'glob');
  46.     }
  47.     protected function configureRoutes(RouteCollectionBuilder $routes)
  48.     {
  49.         $confDir dirname(__DIR__).'/config';
  50.         if (is_dir($confDir.'/routes/')) {
  51.             $routes->import($confDir.'/routes/*'.self::CONFIG_EXTS'/''glob');
  52.         }
  53.         if (is_dir($confDir.'/routes/'.$this->environment)) {
  54.             $routes->import($confDir.'/routes/'.$this->environment.'/**/*'.self::CONFIG_EXTS'/''glob');
  55.         }
  56.         $routes->import($confDir.'/routes'.self::CONFIG_EXTS'/''glob');
  57.     }
  58.     protected function build(ContainerBuilder $container): void
  59.     {
  60.         parent::build($container);
  61.         $container->registerForAutoconfiguration(IVoter::class)->addTag('hrm.acl.voter');
  62.         $container->registerForAutoconfiguration(SuperAdminIVoter::class)->addTag('hrm.acl.super_admin.voter');
  63.         $container->registerForAutoconfiguration(CalendarClientProviderInterface::class)
  64.             ->addTag('hrm.caldav_client.provider');
  65.         $container->registerForAutoconfiguration(EventSubscriber::class)
  66.             ->addTag('doctrine.event_subscriber');
  67.         $container->addCompilerPass(new CalDavClientProviderPass());
  68.         $container->addCompilerPass(new CustomDomainPass());
  69.     }
  70. }