Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)
This commit is contained in:
@@ -9,21 +9,18 @@
|
||||
|
||||
namespace App\DependencyInjection;
|
||||
|
||||
use App\Constants;
|
||||
use App\Kernel;
|
||||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\Intl\Locales;
|
||||
|
||||
/**
|
||||
* This class that loads and manages the Kimai configuration and container parameter.
|
||||
*/
|
||||
class AppExtension extends Extension
|
||||
final class AppExtension extends Extension
|
||||
{
|
||||
/**
|
||||
* @param array $configs
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
public function load(array $configs, ContainerBuilder $container): void
|
||||
{
|
||||
$configuration = new Configuration();
|
||||
try {
|
||||
@@ -33,15 +30,7 @@ class AppExtension extends Extension
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// @deprecated since 0.9, duration_only will be removed with 2.0
|
||||
if (isset($config['timesheet']['duration_only'])) {
|
||||
@trigger_error('Configuration "kimai.timesheet.duration_only" is deprecated, please remove it', E_USER_DEPRECATED);
|
||||
if (true === $config['timesheet']['duration_only'] && 'duration_only' !== $config['timesheet']['mode']) {
|
||||
trigger_error('Found ambiguous configuration: remove "kimai.timesheet.duration_only" and set "kimai.timesheet.mode" instead.');
|
||||
}
|
||||
}
|
||||
|
||||
// we use a comma sepearated string internally, to be able to use it in combination with the database configuration system
|
||||
// we use a comma separated string internally, to be able to use it in combination with the database configuration system
|
||||
foreach ($config['timesheet']['rounding'] as $name => $settings) {
|
||||
$config['timesheet']['rounding'][$name]['days'] = implode(',', $settings['days']);
|
||||
}
|
||||
@@ -56,21 +45,14 @@ class AppExtension extends Extension
|
||||
$config['data_dir'] = $container->getParameter('kernel.project_dir') . '/var/data';
|
||||
}
|
||||
$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') . Kernel::PLUGIN_DIRECTORY);
|
||||
|
||||
$this->setLanguageFormats($config['languages'], $container);
|
||||
unset($config['languages']);
|
||||
$this->setLanguageFormats($container);
|
||||
|
||||
$container->setParameter('kimai.calendar', $config['calendar']); // @deprecated since 1.13
|
||||
$container->setParameter('kimai.dashboard', $config['dashboard']);
|
||||
$container->setParameter('kimai.widgets', $config['widgets']);
|
||||
$container->setParameter('kimai.invoice.documents', $config['invoice']['documents']);
|
||||
$container->setParameter('kimai.export.documents', $config['export']['documents']);
|
||||
$container->setParameter('kimai.defaults', $config['defaults']); // @deprecated since 1.13
|
||||
|
||||
$this->createPermissionParameter($config['permissions'], $container);
|
||||
$container->setParameter('kimai.theme', $config['theme']); // @deprecated since 1.15
|
||||
$container->setParameter('kimai.timesheet', $config['timesheet']); // @deprecated since 1.13
|
||||
$container->setParameter('kimai.timesheet.rates', $config['timesheet']['rates']);
|
||||
$container->setParameter('kimai.timesheet.rounding', $config['timesheet']['rounding']);
|
||||
|
||||
@@ -86,58 +68,77 @@ class AppExtension extends Extension
|
||||
$config['ldap']['connection']['accountFilterFormat'] = '(&' . $filter . '(' . $config['ldap']['user']['usernameAttribute'] . '=%s))';
|
||||
}
|
||||
|
||||
// @deprecated since 1.15
|
||||
$container->setParameter('kimai.ldap', $config['ldap']);
|
||||
|
||||
// translation files, which can overwrite the default kimai translations
|
||||
$localTranslations = [];
|
||||
if (null !== $config['theme']['branding']['translation']) {
|
||||
$localTranslations[] = $config['theme']['branding']['translation'];
|
||||
}
|
||||
if (null !== $config['industry']['translation']) {
|
||||
$localTranslations[] = $config['industry']['translation'];
|
||||
}
|
||||
$container->setParameter('kimai.i18n_domains', $localTranslations);
|
||||
|
||||
// this should happen always at the end, so bundles do not mess with the base configuration
|
||||
/* @phpstan-ignore-next-line */
|
||||
if ($container->hasParameter('kimai.bundles.config')) {
|
||||
$bundleConfig = $container->getParameter('kimai.bundles.config');
|
||||
if (!\is_array($bundleConfig)) {
|
||||
trigger_error('Invalid bundle configuration found, skipping all bundle configuration');
|
||||
}
|
||||
foreach ($bundleConfig as $key => $value) {
|
||||
if (\array_key_exists($key, $config)) {
|
||||
trigger_error(sprintf('Invalid bundle configuration "%s" found, skipping', $key));
|
||||
continue;
|
||||
} else {
|
||||
foreach ($bundleConfig as $key => $value) {
|
||||
if (\array_key_exists($key, $config)) {
|
||||
trigger_error(sprintf('Invalid bundle configuration "%s" found, skipping', $key));
|
||||
continue;
|
||||
}
|
||||
$config[$key] = $value;
|
||||
}
|
||||
$config[$key] = $value;
|
||||
}
|
||||
}
|
||||
$container->setParameter('kimai.config', $config);
|
||||
|
||||
// cleanup for caching
|
||||
unset($config['invoice']['documents']);
|
||||
unset($config['export']);
|
||||
unset($config['dashboard']);
|
||||
unset($config['data_dir']);
|
||||
unset($config['permissions']);
|
||||
|
||||
// make configs a flat dotted notation during compile time, this will save us from the need to
|
||||
// parse each and every call to the config, but allows direct access
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($config, \RecursiveArrayIterator::CHILD_ARRAYS_ONLY));
|
||||
$newConfig = [];
|
||||
foreach ($iterator as $value) {
|
||||
$keys = [];
|
||||
foreach (range(0, $iterator->getDepth()) as $depth) {
|
||||
$keys[] = $iterator->getSubIterator($depth)->key();
|
||||
}
|
||||
$newConfig[implode('.', $keys)] = $value;
|
||||
}
|
||||
|
||||
$container->setParameter('kimai.config', $newConfig);
|
||||
}
|
||||
|
||||
protected function setLanguageFormats(array $config, ContainerBuilder $container)
|
||||
private function setLanguageFormats(ContainerBuilder $container): void
|
||||
{
|
||||
$locales = explode('|', $container->getParameter('app_locales'));
|
||||
|
||||
$directory = $container->getParameter('kernel.project_dir');
|
||||
$config = $directory . DIRECTORY_SEPARATOR . 'config/locales.php';
|
||||
$settings = include $config;
|
||||
|
||||
$appLocales = [];
|
||||
$defaults = [
|
||||
'date' => 'dd.MM.y',
|
||||
'time' => 'HH:mm',
|
||||
'rtl' => false,
|
||||
];
|
||||
|
||||
// make sure all allowed locales are registered
|
||||
foreach ($locales as $locale) {
|
||||
if (!\array_key_exists($locale, $config)) {
|
||||
$config[$locale] = $config[Constants::DEFAULT_LOCALE];
|
||||
}
|
||||
}
|
||||
|
||||
// make sure all keys are registered for every locale
|
||||
foreach ($config as $locale => $settings) {
|
||||
if ($locale === Constants::DEFAULT_LOCALE) {
|
||||
// unlikely that a locale disappears, but in case that a new symfony update comes with changed locales
|
||||
if (!Locales::exists($locale)) {
|
||||
continue;
|
||||
}
|
||||
// pre-fill all formats with the default locale settings
|
||||
$config[$locale] = array_merge($config[Constants::DEFAULT_LOCALE], $config[$locale]);
|
||||
|
||||
$appLocales[$locale] = $defaults;
|
||||
|
||||
if (\array_key_exists($locale, $settings)) {
|
||||
$appLocales[$locale] = array_merge($appLocales[$locale], $settings[$locale]);
|
||||
}
|
||||
}
|
||||
|
||||
$container->setParameter('kimai.languages', $config);
|
||||
ksort($appLocales);
|
||||
|
||||
$container->setParameter('kimai.languages', $appLocales);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,8 +148,20 @@ class AppExtension extends Extension
|
||||
* @param array $config
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
protected function createPermissionParameter(array $config, ContainerBuilder $container)
|
||||
private function createPermissionParameter(array $config, ContainerBuilder $container): void
|
||||
{
|
||||
$names = [];
|
||||
// this does not include all possible permission, as plugins do not register them and Kimai defines a couple of
|
||||
// permissions as well, which are off by default for all roles
|
||||
foreach ($config['sets'] as $set => $permNames) {
|
||||
foreach ($permNames as $name) {
|
||||
if (str_starts_with($name, '@') || str_starts_with($name, '!')) {
|
||||
continue;
|
||||
}
|
||||
$names[$name] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$roles = [];
|
||||
foreach ($config['maps'] as $role => $sets) {
|
||||
foreach ($sets as $set) {
|
||||
@@ -167,30 +180,50 @@ class AppExtension extends Extension
|
||||
|
||||
// delete forbidden permissions from roles
|
||||
foreach (array_keys($config['maps']) as $name) {
|
||||
$config['roles'][$name] = $this->getFilteredPermissions(
|
||||
array_unique(array_merge($roles[$name], $config['roles'][$name] ?? []))
|
||||
);
|
||||
if (\array_key_exists($name, $config['roles'])) {
|
||||
foreach ($config['roles'][$name] as $name2) {
|
||||
$roles[$name][$name2] = true;
|
||||
}
|
||||
}
|
||||
$config['roles'][$name] = $this->getFilteredPermissions($roles[$name]);
|
||||
}
|
||||
|
||||
// make sure to apply all other permissions that might have been registered through plugins
|
||||
foreach ($config['roles'] as $role => $perms) {
|
||||
$names = array_merge($names, $perms);
|
||||
}
|
||||
|
||||
/** @var array<string, array<string>> $roles */
|
||||
$securityRoles = $container->getParameter('security.role_hierarchy.roles');
|
||||
$roles = [];
|
||||
foreach ($securityRoles as $key => $value) {
|
||||
$roles[] = $key;
|
||||
foreach ($value as $name) {
|
||||
$roles[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$container->setParameter('kimai.permissions', $config['roles']);
|
||||
$container->setParameter('kimai.permission_names', $names);
|
||||
$container->setParameter('kimai.permission_roles', array_map('strtoupper', array_values(array_unique($roles))));
|
||||
}
|
||||
|
||||
protected function getFilteredPermissions(array $permissions): array
|
||||
private function getFilteredPermissions(array $permissions): array
|
||||
{
|
||||
$deleteFromArray = array_filter($permissions, function ($permission) {
|
||||
return $permission[0] == '!';
|
||||
});
|
||||
$deleteFromArray = array_filter($permissions, function ($permission): bool {
|
||||
return $permission[0] === '!';
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
|
||||
return array_filter($permissions, function ($permission) use ($deleteFromArray) {
|
||||
if ($permission[0] == '!') {
|
||||
return array_filter($permissions, function ($permission) use ($deleteFromArray): bool {
|
||||
if ($permission[0] === '!') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !\in_array('!' . $permission, $deleteFromArray);
|
||||
});
|
||||
return !\array_key_exists('!' . $permission, $deleteFromArray);
|
||||
}, ARRAY_FILTER_USE_KEY);
|
||||
}
|
||||
|
||||
protected function extractSinglePermissionsFromSet(array $permissions, string $name): array
|
||||
private function extractSinglePermissionsFromSet(array $permissions, string $name): array
|
||||
{
|
||||
if (!isset($permissions['sets'][$name])) {
|
||||
throw new InvalidConfigurationException('Unknown permission set "' . $name . '"');
|
||||
@@ -199,23 +232,20 @@ class AppExtension extends Extension
|
||||
$result = [];
|
||||
|
||||
foreach ($permissions['sets'][$name] as $permissionName) {
|
||||
if ($permissionName[0] == '@') {
|
||||
if ($permissionName[0] === '@') {
|
||||
$result = array_merge(
|
||||
$result,
|
||||
$this->extractSinglePermissionsFromSet($permissions, substr($permissionName, 1))
|
||||
);
|
||||
} else {
|
||||
$result[] = $permissionName;
|
||||
$result[$permissionName] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAlias()
|
||||
public function getAlias(): string
|
||||
{
|
||||
return 'kimai';
|
||||
}
|
||||
|
||||
@@ -23,13 +23,9 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
/**
|
||||
* Dynamically adds all dependencies to the ExportService.
|
||||
*/
|
||||
class ExportServiceCompilerPass implements CompilerPassInterface
|
||||
final class ExportServiceCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$definition = $container->findDefinition(ServiceExport::class);
|
||||
|
||||
@@ -48,7 +44,7 @@ class ExportServiceCompilerPass implements CompilerPassInterface
|
||||
$definition->addMethodCall('addExportRepository', [new Reference($id)]);
|
||||
}
|
||||
|
||||
$path = \dirname(\dirname(\dirname(__DIR__))) . DIRECTORY_SEPARATOR;
|
||||
$path = \dirname(__DIR__, 3) . DIRECTORY_SEPARATOR;
|
||||
foreach ($container->getParameter('kimai.export.documents') as $exportPath) {
|
||||
if (!is_dir($path . $exportPath)) {
|
||||
continue;
|
||||
|
||||
@@ -18,13 +18,9 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
/**
|
||||
* Dynamically adds all dependencies to the InvoiceService.
|
||||
*/
|
||||
class InvoiceServiceCompilerPass implements CompilerPassInterface
|
||||
final class InvoiceServiceCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$definition = $container->findDefinition(ServiceInvoice::class);
|
||||
|
||||
|
||||
@@ -9,26 +9,21 @@
|
||||
|
||||
namespace App\DependencyInjection\Compiler;
|
||||
|
||||
use App\Configuration\ThemeConfiguration;
|
||||
use App\Twig\Configuration;
|
||||
use App\Twig\Context;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* Dynamically adds twig globals.
|
||||
*/
|
||||
class TwigContextCompilerPass implements CompilerPassInterface
|
||||
final class TwigContextCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$twig = $container->getDefinition('twig');
|
||||
|
||||
// @deprecated since 1.15
|
||||
$theme = $container->getDefinition(ThemeConfiguration::class);
|
||||
$theme = $container->getDefinition(Context::class);
|
||||
$twig->addMethodCall('addGlobal', ['kimai_context', $theme]);
|
||||
|
||||
$config = $container->getDefinition(Configuration::class);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace App\DependencyInjection\Compiler;
|
||||
|
||||
use App\Kernel;
|
||||
use App\Repository\WidgetRepository;
|
||||
use App\Widget\WidgetService;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@@ -18,15 +18,11 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
/**
|
||||
* Dynamically adds all widgets to the WidgetRepository.
|
||||
*/
|
||||
class WidgetCompilerPass implements CompilerPassInterface
|
||||
final class WidgetCompilerPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function process(ContainerBuilder $container)
|
||||
public function process(ContainerBuilder $container): void
|
||||
{
|
||||
$definition = $container->findDefinition(WidgetRepository::class);
|
||||
$definition = $container->findDefinition(WidgetService::class);
|
||||
|
||||
$taggedRenderer = $container->findTaggedServiceIds(Kernel::TAG_WIDGET);
|
||||
foreach ($taggedRenderer as $id => $tags) {
|
||||
|
||||
@@ -9,27 +9,16 @@
|
||||
|
||||
namespace App\DependencyInjection;
|
||||
|
||||
use App\Constants;
|
||||
use App\Entity\Customer;
|
||||
use App\Entity\User;
|
||||
use App\Repository\InvoiceDocumentRepository;
|
||||
use App\Timesheet\Rounding\RoundingInterface;
|
||||
use App\Widget\Type\CompoundRow;
|
||||
use App\Widget\Type\Counter;
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* This class validates and merges configuration from the files:
|
||||
* - config/packages/kimai.yaml
|
||||
* - config/packages/local.yaml
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
final class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder(): TreeBuilder
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('kimai');
|
||||
@@ -51,25 +40,20 @@ class Configuration implements ConfigurationInterface
|
||||
->thenInvalid('Data directory does not exist')
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('plugin_dir')
|
||||
->setDeprecated('Changing the plugin directory via "kimai.plugin_dir" is not supported since 1.9')
|
||||
->end()
|
||||
->append($this->getUserNode())
|
||||
->append($this->getCustomerNode())
|
||||
->append($this->getTimesheetNode())
|
||||
->append($this->getInvoiceNode())
|
||||
->append($this->getExportNode())
|
||||
->append($this->getLanguagesNode())
|
||||
->append($this->getCalendarNode())
|
||||
->append($this->getThemeNode())
|
||||
->append($this->getCompanyNode())
|
||||
->append($this->getIndustryNode())
|
||||
->append($this->getDashboardNode())
|
||||
->append($this->getWidgetsNode())
|
||||
->append($this->getDefaultsNode())
|
||||
->append($this->getPermissionsNode())
|
||||
->append($this->getLdapNode())
|
||||
->append($this->getSamlNode())
|
||||
->append($this->getQuickEntryNode())
|
||||
->append($this->getActivityNode())
|
||||
->append($this->getProjectNode())
|
||||
->end()
|
||||
->end();
|
||||
@@ -77,7 +61,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $treeBuilder;
|
||||
}
|
||||
|
||||
private function getQuickEntryNode()
|
||||
private function getQuickEntryNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('quick_entry');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -119,6 +103,24 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getActivityNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('activity');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
$node = $builder->getRootNode();
|
||||
|
||||
$node
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->booleanNode('allow_inline_create')
|
||||
->defaultValue(false)
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getTimesheetNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('timesheet');
|
||||
@@ -130,17 +132,14 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('default_begin')
|
||||
->defaultValue('now')
|
||||
->end()
|
||||
->booleanNode('duration_only')
|
||||
->setDeprecated()
|
||||
->end()
|
||||
->scalarNode('mode')
|
||||
->defaultValue('default')
|
||||
->end()
|
||||
->booleanNode('markdown_content')
|
||||
->defaultValue(false)
|
||||
->end()
|
||||
->scalarNode('duration_increment')
|
||||
->defaultNull()
|
||||
->integerNode('duration_increment')
|
||||
->defaultValue(15)
|
||||
->validate()
|
||||
->ifTrue(function ($value) {
|
||||
if ($value !== null) {
|
||||
@@ -152,8 +151,8 @@ class Configuration implements ConfigurationInterface
|
||||
->thenInvalid('Duration increment is invalid')
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('time_increment')
|
||||
->defaultNull()
|
||||
->integerNode('time_increment')
|
||||
->defaultValue(15)
|
||||
->validate()
|
||||
->ifTrue(function ($value) {
|
||||
if ($value !== null) {
|
||||
@@ -241,16 +240,6 @@ class Configuration implements ConfigurationInterface
|
||||
->arrayNode('active_entries')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->integerNode('soft_limit')
|
||||
->defaultValue(1)
|
||||
->setDeprecated('The node "%node%" at path "%path%" is deprecated, please use "kimai.timesheet.active_entries.hard_limit" instead.')
|
||||
->validate()
|
||||
->ifTrue(function ($value) {
|
||||
return $value <= 0;
|
||||
})
|
||||
->thenInvalid('The soft_limit must be at least 1')
|
||||
->end()
|
||||
->end()
|
||||
->integerNode('hard_limit')
|
||||
->defaultValue(1)
|
||||
->validate()
|
||||
@@ -296,7 +285,10 @@ class Configuration implements ConfigurationInterface
|
||||
->defaultValue(0)
|
||||
->end()
|
||||
->integerNode('long_running_duration')
|
||||
->defaultValue(0)
|
||||
->defaultValue(480)
|
||||
->end()
|
||||
->booleanNode('require_activity')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
@@ -327,9 +319,6 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarPrototype()->end()
|
||||
->defaultValue([])
|
||||
->end()
|
||||
->booleanNode('simple_form')
|
||||
->defaultFalse()
|
||||
->end()
|
||||
->scalarNode('number_format')
|
||||
->defaultValue('{Y}/{cy,3}')
|
||||
->end()
|
||||
@@ -339,7 +328,7 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getExportNode()
|
||||
private function getExportNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('export');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
@@ -366,36 +355,6 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getLanguagesNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('languages');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
$node = $builder->getRootNode();
|
||||
|
||||
$node
|
||||
->useAttributeAsKey('name', false) // see https://github.com/symfony/symfony/issues/18988
|
||||
->arrayPrototype()
|
||||
->children()
|
||||
->scalarNode('date_time_type') // for DateTimeType
|
||||
->defaultValue('yyyy-MM-dd HH:mm')
|
||||
->setDeprecated('date_time_type is deprecated since 1.16 and was replaced by the 24 user configuration')
|
||||
->end()
|
||||
->scalarNode('date_type')->defaultValue('yyyy-MM-dd')->end() // for DateType
|
||||
->scalarNode('date')->defaultValue('Y-m-d')->end() // for display via twig
|
||||
->scalarNode('date_time')->defaultValue('m-d H:i')->end() // for display via twig
|
||||
->scalarNode('duration')->defaultValue('%%h:%%m h')->end() // for display via twig
|
||||
->scalarNode('time')->defaultValue('H:i')->end() // for display via twig
|
||||
->booleanNode('24_hours') // for DateTimeType JS component
|
||||
->defaultTrue()
|
||||
->setDeprecated('24_hours is deprecated since 1.16 and a user configuration now')
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getCalendarNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('calendar');
|
||||
@@ -411,11 +370,6 @@ class Configuration implements ConfigurationInterface
|
||||
->arrayNode('businessHours')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('days')
|
||||
->requiresAtLeastOneElement()
|
||||
->integerPrototype()->end()
|
||||
->defaultValue([1, 2, 3, 4, 5])
|
||||
->end()
|
||||
->scalarNode('begin')->defaultValue('08:00')->end()
|
||||
->scalarNode('end')->defaultValue('20:00')->end()
|
||||
->end()
|
||||
@@ -445,7 +399,7 @@ class Configuration implements ConfigurationInterface
|
||||
->end()
|
||||
->booleanNode('weekends')->defaultTrue()->end()
|
||||
->integerNode('dragdrop_amount')
|
||||
->defaultValue(10)
|
||||
->defaultValue(5)
|
||||
->validate()
|
||||
->ifTrue(static function ($v) {
|
||||
if ($v === null || $v < 0 || $v > 20) {
|
||||
@@ -477,21 +431,6 @@ class Configuration implements ConfigurationInterface
|
||||
$node
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->integerNode('active_warning')
|
||||
->defaultValue(3)
|
||||
->setDeprecated('The node "%node%" at path "%path%" is deprecated, please use "kimai.timesheet.active_entries.soft_limit" instead.')
|
||||
->end()
|
||||
->scalarNode('box_color')
|
||||
->defaultValue('blue')
|
||||
->setDeprecated('The node "%node%" at path "%path%" was removed, please delete it from your config.')
|
||||
->end()
|
||||
->scalarNode('select_type')
|
||||
->defaultValue('selectpicker')
|
||||
->setDeprecated()
|
||||
->end()
|
||||
->booleanNode('tags_create')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->booleanNode('show_about')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
@@ -508,21 +447,6 @@ class Configuration implements ConfigurationInterface
|
||||
'Purple|#800080', 'Fuchsia|#ff00ff', 'Violet|#ee82ee', 'Rose|#ffe4e1', 'Lavender|#E6E6FA'
|
||||
]))
|
||||
->end()
|
||||
->arrayNode('chart')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('background_color')->defaultValue('#3c8dbc')->end() // rgba(0,115,183,0.7) = #0073b7 = Constants::DEFAULT_COLOR
|
||||
->scalarNode('border_color')->defaultValue('#3b8bba')->end()
|
||||
->scalarNode('grid_color')->defaultValue('rgba(0,0,0,.05)')->end()
|
||||
->scalarNode('height')->defaultValue('200')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('calendar')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('background_color')->defaultValue(Constants::DEFAULT_COLOR)->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('branding')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
@@ -538,17 +462,8 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('title')
|
||||
->defaultNull()
|
||||
->end()
|
||||
->scalarNode('translation')
|
||||
->defaultNull()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->integerNode('autocomplete_chars')
|
||||
->defaultValue(3)
|
||||
->end()
|
||||
->booleanNode('random_colors')
|
||||
->defaultTrue()
|
||||
->end()
|
||||
->booleanNode('avatar_url')
|
||||
->defaultFalse()
|
||||
->end()
|
||||
@@ -558,22 +473,6 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getIndustryNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('industry');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
$node = $builder->getRootNode();
|
||||
|
||||
$node
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('translation')->defaultNull()->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getCompanyNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('company');
|
||||
@@ -620,55 +519,17 @@ class Configuration implements ConfigurationInterface
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getWidgetsNode(): ArrayNodeDefinition
|
||||
private function getCustomerNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('widgets');
|
||||
$builder = new TreeBuilder('customer');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
$node = $builder->getRootNode();
|
||||
|
||||
$node
|
||||
->requiresAtLeastOneElement()
|
||||
->useAttributeAsKey('key')
|
||||
->arrayPrototype()
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('title')->isRequired()->end()
|
||||
->scalarNode('query')->isRequired()->end()
|
||||
->booleanNode('user')->defaultFalse()->end()
|
||||
->scalarNode('begin')->end()
|
||||
->scalarNode('end')->end()
|
||||
->scalarNode('icon')->defaultValue('')->end()
|
||||
->scalarNode('color')->defaultValue('')->end()
|
||||
->scalarNode('type')->defaultValue(Counter::class)->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
private function getDashboardNode(): ArrayNodeDefinition
|
||||
{
|
||||
$builder = new TreeBuilder('dashboard');
|
||||
/** @var ArrayNodeDefinition $node */
|
||||
$node = $builder->getRootNode();
|
||||
|
||||
$node
|
||||
->requiresAtLeastOneElement()
|
||||
->useAttributeAsKey('key')
|
||||
->arrayPrototype()
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('type')->defaultValue(CompoundRow::class)->end()
|
||||
->integerNode('order')->defaultValue(0)->end()
|
||||
->scalarNode('title')->end()
|
||||
->scalarNode('permission')->defaultNull()->end()
|
||||
->arrayNode('widgets')
|
||||
->isRequired()
|
||||
->performNoDeepMerging()
|
||||
->scalarPrototype()
|
||||
->end()
|
||||
->end()
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('number_format')
|
||||
->defaultValue('{cc,4}')
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
@@ -693,18 +554,12 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('currency')->defaultValue(Customer::DEFAULT_CURRENCY)->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('timesheet')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->booleanNode('billable')->defaultTrue()->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('user')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('timezone')->defaultNull()->end()
|
||||
->scalarNode('language')->defaultValue(User::DEFAULT_LANGUAGE)->end()
|
||||
->scalarNode('theme')->defaultNull()->end()
|
||||
->scalarNode('theme')->defaultValue('default')->end()
|
||||
->scalarNode('currency')->defaultValue(Customer::DEFAULT_CURRENCY)->end()
|
||||
->end()
|
||||
->end()
|
||||
@@ -902,6 +757,9 @@ class Configuration implements ConfigurationInterface
|
||||
->scalarNode('title')
|
||||
->defaultValue('Login with SAML')
|
||||
->end()
|
||||
->scalarNode('provider')
|
||||
->defaultNull()
|
||||
->end()
|
||||
->arrayNode('roles')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
|
||||
Reference in New Issue
Block a user