configuration improvements (#1784)
This commit is contained in:
@@ -298,11 +298,3 @@ kimai:
|
|||||||
date: 'd. m. Y'
|
date: 'd. m. Y'
|
||||||
date_time: 'd. m. H:i'
|
date_time: 'd. m. H:i'
|
||||||
# --------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------
|
|
||||||
# STORAGE
|
|
||||||
# That's the place where plugins can store static content
|
|
||||||
# --------------------------------------------------------------------------------
|
|
||||||
data_dir: '%kernel.project_dir%/var/data'
|
|
||||||
# --------------------------------------------------------------------------------
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ use Symfony\Component\Console\Command\Command;
|
|||||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||||
use Symfony\Component\Console\Input\ArrayInput;
|
use Symfony\Component\Console\Input\ArrayInput;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
@@ -57,6 +58,7 @@ final class InstallCommand extends Command
|
|||||||
->setName('kimai:install')
|
->setName('kimai:install')
|
||||||
->setDescription('Basic installation for Kimai')
|
->setDescription('Basic installation for Kimai')
|
||||||
->setHelp('This command will perform the basic installation steps to get Kimai up and running.')
|
->setHelp('This command will perform the basic installation steps to get Kimai up and running.')
|
||||||
|
->addOption('no-cache', null, InputOption::VALUE_NONE, 'Skip cache re-generation')
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,8 +97,10 @@ final class InstallCommand extends Command
|
|||||||
return self::ERROR_MIGRATIONS;
|
return self::ERROR_MIGRATIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$input->getOption('no-cache')) {
|
||||||
// flush the cache, just to make sure ... and ignore result
|
// flush the cache, just to make sure ... and ignore result
|
||||||
$this->rebuildCaches($environment, $io, $input, $output);
|
$this->rebuildCaches($environment, $io, $input, $output);
|
||||||
|
}
|
||||||
|
|
||||||
$io->success(
|
$io->success(
|
||||||
sprintf('Congratulations! Successfully installed %s version %s (%s)', Constants::SOFTWARE, Constants::VERSION, Constants::STATUS)
|
sprintf('Congratulations! Successfully installed %s version %s (%s)', Constants::SOFTWARE, Constants::VERSION, Constants::STATUS)
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ class Constants
|
|||||||
/**
|
/**
|
||||||
* The current release version
|
* The current release version
|
||||||
*/
|
*/
|
||||||
public const VERSION = '1.9';
|
public const VERSION = '1.10';
|
||||||
/**
|
/**
|
||||||
* The current release status, either "stable" or "dev"
|
* The current release status, either "stable" or "dev"
|
||||||
*/
|
*/
|
||||||
public const STATUS = 'stable';
|
public const STATUS = 'dev';
|
||||||
/**
|
/**
|
||||||
* The software name
|
* The software name
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ class AppExtension extends Extension
|
|||||||
$config['export']['documents'] = array_merge($config['export']['documents'], $config['export']['defaults']);
|
$config['export']['documents'] = array_merge($config['export']['documents'], $config['export']['defaults']);
|
||||||
unset($config['export']['defaults']);
|
unset($config['export']['defaults']);
|
||||||
|
|
||||||
// safe alternatives to %kernel.project_dir%
|
if (empty($config['data_dir'])) {
|
||||||
|
$config['data_dir'] = $container->getParameter('kernel.project_dir') . '/var/data';
|
||||||
|
}
|
||||||
$container->setParameter('kimai.data_dir', $config['data_dir']);
|
$container->setParameter('kimai.data_dir', $config['data_dir']);
|
||||||
$container->setParameter('kimai.plugin_dir', $container->getParameter('kernel.project_dir') . '/var/plugins');
|
$container->setParameter('kimai.plugin_dir', $container->getParameter('kernel.project_dir') . '/var/plugins');
|
||||||
|
|
||||||
|
|||||||
@@ -37,9 +37,13 @@ class Configuration implements ConfigurationInterface
|
|||||||
$node
|
$node
|
||||||
->children()
|
->children()
|
||||||
->scalarNode('data_dir')
|
->scalarNode('data_dir')
|
||||||
->isRequired()
|
->defaultNull()
|
||||||
->validate()
|
->validate()
|
||||||
->ifTrue(function ($value) {
|
->ifTrue(function ($value) {
|
||||||
|
if (null === $value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return !file_exists($value);
|
return !file_exists($value);
|
||||||
})
|
})
|
||||||
->thenInvalid('Data directory does not exist')
|
->thenInvalid('Data directory does not exist')
|
||||||
|
|||||||
@@ -9,19 +9,26 @@
|
|||||||
|
|
||||||
namespace App\Security;
|
namespace App\Security;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Driver\PDOConnection;
|
||||||
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
|
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler;
|
||||||
|
|
||||||
class SessionHandler extends PdoSessionHandler
|
class SessionHandler extends PdoSessionHandler
|
||||||
{
|
{
|
||||||
public function __construct($pdoOrDsn = null)
|
public function __construct($pdoOrDsn = null)
|
||||||
{
|
{
|
||||||
|
$lockMode = PdoSessionHandler::LOCK_NONE;
|
||||||
|
|
||||||
|
if ($pdoOrDsn instanceof PDOConnection && $pdoOrDsn->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'mysql') {
|
||||||
|
$lockMode = PdoSessionHandler::LOCK_ADVISORY;
|
||||||
|
}
|
||||||
|
|
||||||
parent::__construct($pdoOrDsn, [
|
parent::__construct($pdoOrDsn, [
|
||||||
'db_table' => 'kimai2_sessions',
|
'db_table' => 'kimai2_sessions',
|
||||||
'db_id_col' => 'id',
|
'db_id_col' => 'id',
|
||||||
'db_data_col' => 'data',
|
'db_data_col' => 'data',
|
||||||
'db_lifetime_col' => 'lifetime',
|
'db_lifetime_col' => 'lifetime',
|
||||||
'db_time_col' => 'time',
|
'db_time_col' => 'time',
|
||||||
'lock_mode' => PdoSessionHandler::LOCK_ADVISORY,
|
'lock_mode' => $lockMode,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class AvatarService
|
|||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $projectDirectory;
|
private $directory;
|
||||||
|
|
||||||
public const AVATAR_CONFIG = [
|
public const AVATAR_CONFIG = [
|
||||||
'driver' => 'gd',
|
'driver' => 'gd',
|
||||||
@@ -105,7 +105,17 @@ class AvatarService
|
|||||||
|
|
||||||
public function __construct(string $projectDirectory)
|
public function __construct(string $projectDirectory)
|
||||||
{
|
{
|
||||||
$this->projectDirectory = $projectDirectory;
|
$this->setStorageDirectory($projectDirectory . '/public/avatars/');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getStorageDirectory(): string
|
||||||
|
{
|
||||||
|
return $this->directory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStorageDirectory(string $directory)
|
||||||
|
{
|
||||||
|
$this->directory = realpath($directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAvatarUrl(User $profile): string
|
private function getAvatarUrl(User $profile): string
|
||||||
@@ -115,9 +125,7 @@ class AvatarService
|
|||||||
|
|
||||||
private function getImagePath(User $profile): string
|
private function getImagePath(User $profile): string
|
||||||
{
|
{
|
||||||
$avatarPath = realpath($this->projectDirectory . '/public/avatars/');
|
return $this->getStorageDirectory() . '/' . $this->getAvatarUrl($profile);
|
||||||
|
|
||||||
return $avatarPath . '/' . $this->getAvatarUrl($profile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateAvatar(User $profile, bool $regenerate = false): bool
|
public function generateAvatar(User $profile, bool $regenerate = false): bool
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ final class FileHelper
|
|||||||
$this->filesystem = new Filesystem();
|
$this->filesystem = new Filesystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDataDirectory(string $directory)
|
||||||
|
{
|
||||||
|
$this->dataDir = $directory;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDataDirectory(string $subDirectory = null): string
|
public function getDataDirectory(string $subDirectory = null): string
|
||||||
{
|
{
|
||||||
$directory = $this->dataDir . '/';
|
$directory = $this->dataDir . '/';
|
||||||
|
|||||||
@@ -421,14 +421,6 @@ class AppExtensionTest extends TestCase
|
|||||||
$this->assertEquals(['yyyy', 'xxxx'], $config);
|
$this->assertEquals(['yyyy', 'xxxx'], $config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testInvalidConfiguration()
|
|
||||||
{
|
|
||||||
$this->expectException(Notice::class);
|
|
||||||
$this->expectExceptionMessage('Found invalid "kimai" configuration: The child node "data_dir" at path "kimai" must be configured.');
|
|
||||||
|
|
||||||
$this->extension->load([], $container = $this->getContainer());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testWithBundleConfiguration()
|
public function testWithBundleConfiguration()
|
||||||
{
|
{
|
||||||
$bundleConfig = [
|
$bundleConfig = [
|
||||||
|
|||||||
Reference in New Issue
Block a user