mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-12 19:34:31 +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
|
@ -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