From aa1ea98579015f9a2acf93d4edc54a944b31bbe1 Mon Sep 17 00:00:00 2001 From: Toby Batch Date: Fri, 18 Sep 2020 10:53:53 +0100 Subject: [PATCH] added cwd in kimai:reload command (#1951) --- src/Command/ReloadCommand.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Command/ReloadCommand.php b/src/Command/ReloadCommand.php index 22653e8c..51d946b6 100644 --- a/src/Command/ReloadCommand.php +++ b/src/Command/ReloadCommand.php @@ -30,6 +30,19 @@ final class ReloadCommand extends Command public const ERROR_LINT_CONFIG = 8; public const ERROR_LINT_TRANSLATIONS = 16; + /** + * Returns the base directory to the Kimai installation. + * + * @return string + */ + protected function getRootDirectory(): string + { + /** @var Application $application */ + $application = $this->getApplication(); + + return $application->getKernel()->getProjectDir(); + } + /** * {@inheritdoc} */ @@ -53,6 +66,10 @@ final class ReloadCommand extends Command $io->title('Reloading configurations ...'); + // many users execute the bin/console command from arbitrary locations + $path = getcwd(); + \chdir($this->getRootDirectory()); + try { $command = $this->getApplication()->find('lint:yaml'); $cmdInput = new StringInput('lint:yaml --parse-tags config'); @@ -92,6 +109,8 @@ final class ReloadCommand extends Command // flush the cache, in case values from the database are cached $cacheResult = $this->rebuildCaches($environment, $io, $input, $output); + chdir($path); + if ($cacheResult !== 0) { $io->warning( [