getProjectDir() . '/var/cache/' . $this->environment; } public function getLogDir() { return $this->getProjectDir() . '/var/log'; } protected function build(ContainerBuilder $container) { $container->registerForAutoconfiguration(TimesheetCalculator::class)->addTag(self::TAG_TIMESHEET_CALCULATOR); $container->registerForAutoconfiguration(ExportRendererInterface::class)->addTag(self::TAG_EXPORT_RENDERER); $container->registerForAutoconfiguration(InvoiceRendererInterface::class)->addTag(self::TAG_INVOICE_RENDERER); $container->registerForAutoconfiguration(NumberGeneratorInterface::class)->addTag(self::TAG_INVOICE_NUMBER_GENERATOR); $container->registerForAutoconfiguration(InvoiceCalculator::class)->addTag(self::TAG_INVOICE_CALCULATOR); $container->registerForAutoconfiguration(InvoiceItemRepositoryInterface::class)->addTag(self::TAG_INVOICE_REPOSITORY); $container->registerForAutoconfiguration(PluginInterface::class)->addTag(self::TAG_PLUGIN); $container->registerForAutoconfiguration(WidgetRendererInterface::class)->addTag(self::TAG_WIDGET_RENDERER); $container->registerForAutoconfiguration(WidgetInterface::class)->addTag(self::TAG_WIDGET); /** @var SecurityExtension $extension */ $extension = $container->getExtension('security'); $extension->addSecurityListenerFactory(new FormLoginLdapFactory()); } 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(); } } $pluginsDir = $this->getProjectDir() . '/var/plugins'; if (!file_exists($pluginsDir)) { return; } $finder = new Finder(); $finder->ignoreUnreadableDirs()->directories()->name('*Bundle'); /** @var SplFileInfo $bundleDir */ foreach ($finder->in($pluginsDir) as $bundleDir) { $bundleName = $bundleDir->getRelativePathname(); $bundleFilename = $bundleDir->getRealPath() . '/' . $bundleName . '.php'; if (!file_exists($bundleFilename)) { continue; } $pluginClass = 'KimaiPlugin\\' . $bundleName . '\\' . $bundleName; if (!class_exists($pluginClass)) { continue; } yield new $pluginClass(); } } 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'; // if you want to prepend any config, you can do it here $loader->load($confDir . '/packages/local_before' . self::CONFIG_EXTS, 'glob'); // using this one instead of $loader->load($confDir . '/packages/*' . self::CONFIG_EXTS, 'glob'); // to get rid of the local.yaml from the list, we load it afterwards explicit $finder = (new Finder()) ->files() ->in([$confDir . '/packages/']) ->name('*' . self::CONFIG_EXTS) ->notName('local*' . self::CONFIG_EXTS) ->depth('== 0') ->sortByName() ->followLinks() ; /** @var SplFileInfo $file */ foreach ($finder as $file) { $loader->load($file->getPathname()); } if (is_dir($confDir . '/packages/' . $this->environment)) { $loader->load($confDir . '/packages/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob'); } $loader->load($confDir . '/packages/local' . 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); $container->addCompilerPass(new TwigContextCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1000); $container->addCompilerPass(new InvoiceServiceCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1000); $container->addCompilerPass(new WidgetCompilerPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -1000); } protected function configureRoutes(RouteCollectionBuilder $routes) { $confDir = $this->getProjectDir() . '/config'; // some routes are based on app configs and will be imported manually $this->configureFosUserRoutes($routes); // load bundle specific route files if (is_dir($confDir . '/routes/')) { $routes->import($confDir . '/routes/*' . self::CONFIG_EXTS, '/', 'glob'); } // load environment specific route files if (is_dir($confDir . '/routes/' . $this->environment)) { $routes->import($confDir . '/routes/' . $this->environment . '/**/*' . self::CONFIG_EXTS, '/', 'glob'); } // load application routes $routes->import($confDir . '/routes' . self::CONFIG_EXTS, '/', 'glob'); // load plugin routes $pluginsDir = $this->getProjectDir() . '/var/plugins'; if (!file_exists($pluginsDir)) { return; } $routes->import($pluginsDir . '/*Bundle/Resources/config/routes' . self::CONFIG_EXTS, '/', 'glob'); } protected function configureFosUserRoutes(RouteCollectionBuilder $routes) { $features = $this->getContainer()->getParameter('kimai.fosuser'); // Expose the user registration feature if ($features['registration']) { $routes->import( '@FOSUserBundle/Resources/config/routing/registration.xml', '/{_locale}/register' ); } // Expose the users password-reset feature if ($features['password_reset']) { $routes->import( '@FOSUserBundle/Resources/config/routing/resetting.xml', '/{_locale}/resetting' ); } } }