mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Organized parameters better.
Parameters can now be found in their own file config/parameters.yaml. They are prefixed with partdb. and structured into different sections.
This commit is contained in:
parent
ffdb721e38
commit
decc4e90fc
11 changed files with 86 additions and 57 deletions
|
@ -7,7 +7,7 @@ scheb_two_factor:
|
|||
|
||||
google:
|
||||
enabled: true # If Google Authenticator should be enabled, default false
|
||||
server_name: '%partdb_title%' # Server name used in QR code
|
||||
server_name: '%partdb.title%' # Server name used in QR code
|
||||
issuer: 'Part-DB' # Issuer name used in QR code
|
||||
digits: 6 # Number of digits in authentication code
|
||||
window: 1 # How many codes before/after the current one would be accepted as valid
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
framework:
|
||||
default_locale: '%locale%'
|
||||
default_locale: '%partdb.locale%'
|
||||
translator:
|
||||
default_path: '%kernel.project_dir%/translations'
|
||||
fallbacks:
|
||||
- '%locale%'
|
||||
- '%partdb.locale%'
|
||||
- 'en'
|
||||
|
|
|
@ -6,10 +6,10 @@ twig:
|
|||
'%kernel.project_dir%/assets/css': css
|
||||
|
||||
globals:
|
||||
partdb_title: '%partdb_title%'
|
||||
default_currency: '%default_currency%'
|
||||
global_theme: '%global_theme%'
|
||||
allow_email_pw_reset: '%allow_email_pw_reset%'
|
||||
locale_menu: '%locale_menu%'
|
||||
partdb_title: '%partdb.title%'
|
||||
default_currency: '%partdb.default_currency%'
|
||||
global_theme: '%partdb.global_theme%'
|
||||
allow_email_pw_reset: '%partdb.users.email_pw_reset%'
|
||||
locale_menu: '%partdb.locale_menu%'
|
||||
attachment_manager: '@App\Services\Attachments\AttachmentManager'
|
||||
label_profile_dropdown_helper: '@App\Services\LabelSystem\LabelProfileDropdownHelper'
|
||||
|
|
43
config/parameters.yaml
Normal file
43
config/parameters.yaml
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Here you can configure the global behavior of Part-DB
|
||||
|
||||
parameters:
|
||||
|
||||
######################################################################################################################
|
||||
# Common
|
||||
######################################################################################################################
|
||||
partdb.locale: 'en' # The default language to use serverwide
|
||||
partdb.timezone: 'Europe/Berlin' # The default timezone
|
||||
partdb.title: 'Part-DB' # The title shown inside of Part-DB (e.g. in the navbar and on homepage)
|
||||
partdb.banner: '%env(trim:string:BANNER)%' # The info text shown in the homepage, if empty config/banner.md is used
|
||||
partdb.default_currency: 'EUR' # The currency that is used inside the DB (and is assumed when no currency is set). This can not be changed later, so be sure to set it the currency used in your country
|
||||
partdb.global_theme: '' # The theme to use globally (see public/build/themes/ for choices, use name without .css). Set to '' for default bootstrap theme
|
||||
partdb.locale_menu: ['en', 'de', 'fr', 'ru', 'ja'] # The languages that are shown in user drop down menu
|
||||
|
||||
######################################################################################################################
|
||||
# Users and Privacy
|
||||
######################################################################################################################
|
||||
partdb.gpdr_compliance: true # If this option is activated, IP addresses are anonymized to be GPDR compliant
|
||||
partdb.users.use_gravatar: true # Set to false, if no Gravatar images should be used for user profiles.
|
||||
partdb.users.email_pw_reset: '%env(validMailDSN:MAILER_DSN)%' # Config if users are able, to reset their password by email. By default this enabled, when a mail server is configured.
|
||||
|
||||
######################################################################################################################
|
||||
# Mail settings
|
||||
######################################################################################################################
|
||||
partdb.mail.sender_email: 'noreply@partdb.changeme' # The email address from which all emails are sent from
|
||||
partdb.mail.sender_name: 'Part-DB Mailer' # The name that will be used for all mails sent by Part-DB
|
||||
|
||||
######################################################################################################################
|
||||
# Attachments and files
|
||||
######################################################################################################################
|
||||
partdb.attachments.allow_downloads: false # Allow users to download attachments to server. Warning: This can be dangerous, because via that feature attackers maybe can access ressources on your intranet!
|
||||
partdb.attachments.dir.media: 'public/media/' # The folder where uploaded attachment files are saved (must be in public folder)
|
||||
partdb.attachments.dir.secure: 'uploads/' # The folder where secured attachment files are saved (must not be in public/)
|
||||
|
||||
######################################################################################################################
|
||||
# Miscellaneous
|
||||
######################################################################################################################
|
||||
partdb.demo_mode: '%env(bool:DEMO_MODE)%' # If set to true, all potentially dangerous things are disabled (like changing passwords of the own user)
|
||||
|
||||
|
||||
|
||||
|
|
@ -4,38 +4,18 @@
|
|||
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
||||
|
||||
parameters:
|
||||
locale: 'en' # Set the default language to use her
|
||||
timezone: 'Europe/Berlin'
|
||||
partdb_title: 'Part-DB' # The title shown inside of Part-DB (e.g. in the navbar and on homepage)
|
||||
banner: '%env(trim:string:BANNER)%' # The info text shown in the homepage, if empty config/banner.md is used
|
||||
use_gravatar: true # Set to false, if no Gravatar images should be used for user profiles.
|
||||
default_currency: 'EUR' # The currency that should be used
|
||||
media_directory: 'public/media/' # The folder where uploaded attachment files are saved
|
||||
secure_media_directory: 'uploads/' # The folder where secured attachment files are saved (must not be in public/)
|
||||
global_theme: '' # The theme to use globally (see public/build/themes/ for choices). Set to '' for default bootstrap theme
|
||||
# Allow users to download attachments to server. Warning: This can be dangerous, because via that feature attackers maybe can access ressources on your intranet!
|
||||
allow_attachments_downloads: false
|
||||
demo_mode: '%env(bool:DEMO_MODE)%' # If set to true, all potentially dangerous things are disabled (like changing passwords of the own user)
|
||||
sender_email: 'noreply@partdb.changeme' # The email address from which all emails are sent from
|
||||
sender_name: 'Part-DB Mailer' # The name that will be used for all mails sent by Part-DB
|
||||
allow_email_pw_reset: '%env(validMailDSN:MAILER_DSN)%' # Config if users are able, to reset their password by email. By default this enabled, when a mail server is configured.
|
||||
locale_menu: ['en', 'de', 'fr', 'ru', 'ja'] # The languages that are shown in user drop down menu
|
||||
# If this option is activated, IP addresses are anonymized to be GPDR compliant
|
||||
gpdr_compliance: true
|
||||
|
||||
|
||||
services:
|
||||
# default configuration for services in *this* file
|
||||
_defaults:
|
||||
autowire: true # Automatically injects dependencies in your services.
|
||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
||||
bind:
|
||||
bool $demo_mode: '%demo_mode%'
|
||||
bool $gpdr_compliance : '%gpdr_compliance%'
|
||||
bool $demo_mode: '%partdb.demo_mode%'
|
||||
bool $gpdr_compliance : '%partdb.gpdr_compliance%'
|
||||
bool $kernel_debug: '%kernel.debug%'
|
||||
string $kernel_cache_dir: '%kernel.cache_dir%'
|
||||
string $partdb_title: '%partdb_title%'
|
||||
string $partdb_title: '%partdb.title%'
|
||||
string $default_currency: '%partdb.default_currency%'
|
||||
|
||||
_instanceof:
|
||||
App\Services\LabelSystem\PlaceholderProviders\PlaceholderProviderInterface:
|
||||
|
@ -56,8 +36,8 @@ services:
|
|||
App\EventSubscriber\SetMailFromSubscriber:
|
||||
tags: ['kernel.event_subscriber']
|
||||
arguments:
|
||||
$email: '%sender_email%'
|
||||
$name: '%sender_name%'
|
||||
$email: '%partdb.mail.sender_email%'
|
||||
$name: '%partdb.mail.sender_name%'
|
||||
|
||||
App\Services\LogSystem\EventLogger:
|
||||
arguments:
|
||||
|
@ -111,51 +91,51 @@ services:
|
|||
|
||||
App\Controller\RedirectController:
|
||||
arguments:
|
||||
$default_locale: '%locale%'
|
||||
$default_locale: '%partdb.locale%'
|
||||
$enforce_index_php: '%env(bool:NO_URL_REWRITE_AVAILABLE)%'
|
||||
|
||||
App\Command\UpdateExchangeRatesCommand:
|
||||
arguments:
|
||||
$base_current: '%default_currency%'
|
||||
$base_current: '%partdb.default_currency%'
|
||||
|
||||
App\Form\Type\CurrencyEntityType:
|
||||
arguments:
|
||||
$base_currency: '%default_currency%'
|
||||
$base_currency: '%partdb.default_currency%'
|
||||
|
||||
App\Services\PricedetailHelper:
|
||||
arguments:
|
||||
$base_currency: '%default_currency%'
|
||||
$base_currency: '%partdb.default_currency%'
|
||||
|
||||
App\Services\MoneyFormatter:
|
||||
arguments:
|
||||
$base_currency: '%default_currency%'
|
||||
$base_currency: '%partdb.default_currency%'
|
||||
|
||||
App\Form\AttachmentFormType:
|
||||
arguments:
|
||||
$allow_attachments_downloads: '%allow_attachments_downloads%'
|
||||
$allow_attachments_downloads: '%partdb.attachments.allow_downloads%'
|
||||
|
||||
App\Services\Attachments\AttachmentSubmitHandler:
|
||||
arguments:
|
||||
$allow_attachments_downloads: '%allow_attachments_downloads%'
|
||||
$allow_attachments_downloads: '%partdb.attachments.allow_downloads%'
|
||||
$mimeTypes: '@mime_types'
|
||||
|
||||
App\Form\UserSettingsType:
|
||||
arguments:
|
||||
$demo_mode: '%demo_mode%'
|
||||
$demo_mode: '%partdb.demo_mode%'
|
||||
|
||||
App\EventSubscriber\UserSystem\SetUserTimezoneSubscriber:
|
||||
arguments:
|
||||
$timezone: '%timezone%'
|
||||
$timezone: '%partdb.timezone%'
|
||||
|
||||
App\Controller\SecurityController:
|
||||
arguments:
|
||||
$allow_email_pw_reset: '%allow_email_pw_reset%'
|
||||
$allow_email_pw_reset: '%partdb.users.email_pw_reset%'
|
||||
|
||||
App\Services\Attachments\AttachmentPathResolver:
|
||||
arguments:
|
||||
$project_dir: '%kernel.project_dir%'
|
||||
$media_path: '%media_directory%'
|
||||
$secure_path: '%secure_media_directory%'
|
||||
$media_path: '%partdb.attachments.dir.media%'
|
||||
$secure_path: '%partdb.attachments.dir.secure%'
|
||||
$footprints_path: 'public/img/footprints'
|
||||
$models_path: null
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class HomepageController extends AbstractController
|
|||
|
||||
public function getBanner(): string
|
||||
{
|
||||
$banner = $this->getParameter('banner');
|
||||
$banner = $this->getParameter('partdb.banner');
|
||||
if (empty($banner)) {
|
||||
$banner_path = $this->kernel->getProjectDir()
|
||||
.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'banner.md';
|
||||
|
|
|
@ -193,7 +193,7 @@ class UserController extends AdminPages\BaseAdminController
|
|||
return $table->getResponse();
|
||||
}
|
||||
|
||||
if ($this->getParameter('use_gravatar')) {
|
||||
if ($this->getParameter('partdb.users.use_gravatar')) {
|
||||
$avatar = $this->getGravatar($user->getEmail(), 200, 'identicon');
|
||||
} else {
|
||||
$avatar = $packages->getUrl('/img/default_avatar.png');
|
||||
|
|
|
@ -44,7 +44,6 @@ namespace App\Form\AdminPages;
|
|||
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Services\Attachments\FileTypeFilterTools;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@ -54,10 +53,10 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
|
|||
{
|
||||
protected $filterTools;
|
||||
|
||||
public function __construct(Security $security, ParameterBagInterface $params, FileTypeFilterTools $filterTools)
|
||||
public function __construct(Security $security, FileTypeFilterTools $filterTools)
|
||||
{
|
||||
$this->filterTools = $filterTools;
|
||||
parent::__construct($security, $params);
|
||||
parent::__construct($security);
|
||||
}
|
||||
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void
|
||||
|
|
|
@ -42,7 +42,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Form\AdminPages;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Base\AbstractNamedDBElement;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Entity\LabelSystem\LabelProfile;
|
||||
|
@ -52,7 +51,6 @@ use App\Form\Type\MasterPictureAttachmentType;
|
|||
use App\Form\Type\StructuralEntityType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use function get_class;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
|
@ -66,12 +64,10 @@ use Symfony\Component\Security\Core\Security;
|
|||
class BaseEntityAdminForm extends AbstractType
|
||||
{
|
||||
protected $security;
|
||||
protected $params;
|
||||
|
||||
public function __construct(Security $security, ParameterBagInterface $params)
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
|
|
|
@ -47,9 +47,18 @@ use App\Entity\PriceInformations\Currency;
|
|||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class SupplierForm extends CompanyForm
|
||||
{
|
||||
protected $default_currency;
|
||||
|
||||
public function __construct(Security $security, string $default_currency)
|
||||
{
|
||||
parent::__construct($security);
|
||||
$this->default_currency = $default_currency;
|
||||
}
|
||||
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, AbstractNamedDBElement $entity): void
|
||||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
@ -66,7 +75,7 @@ class SupplierForm extends CompanyForm
|
|||
|
||||
$builder->add('shipping_costs', MoneyType::class, [
|
||||
'required' => false,
|
||||
'currency' => $this->params->get('default_currency'),
|
||||
'currency' => $this->default_currency,
|
||||
'scale' => 3,
|
||||
'label' => 'supplier.shipping_costs.label',
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
|
|
|
@ -57,6 +57,8 @@ class Kernel extends BaseKernel
|
|||
$container->setParameter('container.dumper.inline_factories', true);
|
||||
$confDir = $this->getProjectDir().'/config';
|
||||
|
||||
$loader->load($confDir.'/parameters.yaml');
|
||||
|
||||
$loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob');
|
||||
$loader->load($confDir.'/{packages}/'.$this->environment.'/*'.self::CONFIG_EXTS, 'glob');
|
||||
$loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue