mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-14 20:35:08 +02:00
Applied code style rules to src/
This commit is contained in:
parent
700c049d26
commit
f861de791f
186 changed files with 1462 additions and 1059 deletions
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -39,7 +42,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
|
|||
parent::__construct($security, $params);
|
||||
}
|
||||
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
|
@ -48,7 +51,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
|
|||
'help' => 'attachment_type.edit.filetype_filter.help',
|
||||
'attr' => ['placeholder' => 'attachment_type.edit.filetype_filter.placeholder'],
|
||||
'empty_data' => '',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
//Normalize data before writing it to database
|
||||
$builder->get('filetype_filter')->addViewTransformer(new CallbackTransformer(
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -50,13 +53,13 @@ class BaseEntityAdminForm extends AbstractType
|
|||
$this->params = $params;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
parent::configureOptions($resolver); // TODO: Change the autogenerated stub
|
||||
$resolver->setRequired('attachment_class');
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
/** @var StructuralDBElement $entity */
|
||||
$entity = $options['data'];
|
||||
|
@ -65,22 +68,22 @@ class BaseEntityAdminForm extends AbstractType
|
|||
$builder
|
||||
->add('name', TextType::class, ['empty_data' => '', 'label' => 'name.label',
|
||||
'attr' => ['placeholder' => 'part.name.placeholder'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
|
||||
->add('parent', StructuralEntityType::class, ['class' => \get_class($entity),
|
||||
'required' => false, 'label' => 'parent.label',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ])
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ])
|
||||
|
||||
->add('not_selectable', CheckboxType::class, ['required' => false,
|
||||
'label' => 'entity.edit.not_selectable',
|
||||
'help' => 'entity.edit.not_selectable.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
|
||||
->add('comment', CKEditorType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'comment.label',
|
||||
'attr' => ['rows' => 4], 'help' => 'bbcode.hint',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$this->additionalFormElements($builder, $options, $entity);
|
||||
|
||||
|
@ -90,7 +93,7 @@ class BaseEntityAdminForm extends AbstractType
|
|||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'label' => false,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'entry_options' => [
|
||||
'data_class' => $options['attachment_class'],
|
||||
],
|
||||
|
@ -99,7 +102,7 @@ class BaseEntityAdminForm extends AbstractType
|
|||
|
||||
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'label' => 'part.edit.master_attachment',
|
||||
'entity' => $entity,
|
||||
]);
|
||||
|
@ -108,12 +111,12 @@ class BaseEntityAdminForm extends AbstractType
|
|||
$builder->add('save', SubmitType::class, [
|
||||
'label' => $is_new ? 'entity.create' : 'entity.edit.save',
|
||||
'attr' => ['class' => $is_new ? 'btn-success' : ''],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ])
|
||||
->add('reset', ResetType::class, ['label' => 'entity.edit.reset',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
}
|
||||
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
//Empty for Base
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -28,7 +31,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||
|
||||
class CategoryAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
|
@ -36,44 +39,44 @@ class CategoryAdminForm extends BaseEntityAdminForm
|
|||
'label' => 'category.edit.disable_footprints',
|
||||
'help' => 'category.edit.disable_footprints.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('disable_manufacturers', CheckboxType::class, ['required' => false,
|
||||
'label' => 'category.edit.disable_manufacturers',
|
||||
'help' => 'category.edit.disable_manufacturers.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('disable_autodatasheets', CheckboxType::class, ['required' => false,
|
||||
'label' => 'category.edit.disable_autodatasheets',
|
||||
'help' => 'category.edit.disable_autodatasheets.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('disable_properties', CheckboxType::class, ['required' => false,
|
||||
'label' => 'category.edit.disable_properties',
|
||||
'help' => 'category.edit.disable_properties.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('partname_hint', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'category.edit.partname_hint',
|
||||
'attr' => ['placeholder' => 'category.edit.partname_hint.placeholder'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('partname_regex', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'category.edit.partname_regex',
|
||||
'attr' => ['placeholder' => 'category.edit.partname_regex.placeholder'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('default_description', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'category.edit.default_description',
|
||||
'attr' => ['placeholder' => 'category.edit.default_description.placeholder'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('default_comment', TextType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'category.edit.default_comment',
|
||||
'attr' => ['placeholder' => 'category.edit.default_comment.placeholder'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -30,20 +33,20 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||
|
||||
class CompanyForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
$builder->add('address', TextareaType::class, [
|
||||
'label' => 'company.edit.address',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.address.placeholder'], 'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('phone_number', TelType::class, [
|
||||
'label' => 'company.edit.phone_number',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.phone_number.placeholder'],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
|
@ -51,21 +54,21 @@ class CompanyForm extends BaseEntityAdminForm
|
|||
|
||||
$builder->add('fax_number', TelType::class, [
|
||||
'label' => 'company.edit.fax_number',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.fax_number.placeholder'], 'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('email_address', EmailType::class, [
|
||||
'label' => 'company.edit.email',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.email.placeholder'], 'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
||||
$builder->add('website', UrlType::class, [
|
||||
'label' => 'company.edit.website',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.website.placeholder'], 'required' => false,
|
||||
'empty_data' => '',
|
||||
]);
|
||||
|
@ -73,7 +76,7 @@ class CompanyForm extends BaseEntityAdminForm
|
|||
$builder->add('auto_product_url', UrlType::class, [
|
||||
'label' => 'company.edit.auto_product_url',
|
||||
'help' => 'company.edit.auto_product_url.help',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'attr' => ['placeholder' => 'company.edit.auto_product_url.placeholder'],
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -28,7 +31,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||
|
||||
class CurrencyAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
|
@ -37,13 +40,13 @@ class CurrencyAdminForm extends BaseEntityAdminForm
|
|||
'label' => 'currency.edit.iso_code',
|
||||
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('exchange_rate', MoneyType::class, [
|
||||
'required' => false,
|
||||
'label' => 'currency.edit.exchange_rate',
|
||||
'currency' => $this->params->get('default_currency'),
|
||||
'scale' => 6,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -27,11 +30,11 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||
|
||||
class FootprintAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
public function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
public function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
$builder->add('footprint_3d', MasterPictureAttachmentType::class, [
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted(null === $entity->getID() ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted(null === $entity->getID() ? 'create' : 'edit', $entity),
|
||||
'label' => 'footprint.edit.3d_model',
|
||||
'filter' => '3d_model',
|
||||
'entity' => $entity,
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -28,7 +31,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||
|
||||
class GroupAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
|
@ -36,13 +39,13 @@ class GroupAdminForm extends BaseEntityAdminForm
|
|||
'label' => 'group.edit.enforce_2fa',
|
||||
'help' => 'entity.edit.enforce_2fa.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
$builder->add('permissions', PermissionsType::class, [
|
||||
'mapped' => false,
|
||||
'data' => $builder->getData(),
|
||||
'disabled' => !$this->security->isGranted('edit_permissions', $entity),
|
||||
'disabled' => ! $this->security->isGranted('edit_permissions', $entity),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -41,14 +44,14 @@ class ImportType extends AbstractType
|
|||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$data = $options['data'];
|
||||
|
||||
//Disable import if user is not allowed to create elements.
|
||||
$entity = new $data['entity_class']();
|
||||
$perm_name = 'create';
|
||||
$disabled = !$this->security->isGranted($perm_name, $entity);
|
||||
$disabled = ! $this->security->isGranted($perm_name, $entity);
|
||||
|
||||
$builder
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -38,14 +41,14 @@ class MassCreationForm extends AbstractType
|
|||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$data = $options['data'];
|
||||
|
||||
//Disable import if user is not allowed to create elements.
|
||||
$entity = new $data['entity_class']();
|
||||
$perm_name = 'create';
|
||||
$disabled = !$this->security->isGranted($perm_name, $entity);
|
||||
$disabled = ! $this->security->isGranted($perm_name, $entity);
|
||||
|
||||
$builder
|
||||
->add('lines', TextareaType::class, ['data' => '',
|
||||
|
@ -66,8 +69,8 @@ class MassCreationForm extends AbstractType
|
|||
|
||||
//Buttons
|
||||
$builder->add('create', SubmitType::class, [
|
||||
'label' => 'entity.mass_creation.btn',
|
||||
'disabled' => $disabled,
|
||||
]);
|
||||
'label' => 'entity.mass_creation.btn',
|
||||
'disabled' => $disabled,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -28,7 +31,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||
|
||||
class MeasurementUnitAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
|
@ -36,17 +39,17 @@ class MeasurementUnitAdminForm extends BaseEntityAdminForm
|
|||
'label' => 'measurement_unit.edit.is_integer',
|
||||
'help' => 'measurement_unit.edit.is_integer.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('use_si_prefix', CheckboxType::class, ['required' => false,
|
||||
'label' => 'measurement_unit.edit.use_si_prefix',
|
||||
'help' => 'measurement_unit.edit.use_si_prefix.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
|
||||
$builder->add('unit', TextType::class, ['required' => false,
|
||||
'label' => 'measurement_unit.edit.unit_symbol',
|
||||
'attr' => ['placeholder' => 'measurement_unit.edit.unit_symbol.placeholder'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity), ]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -29,7 +32,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||
|
||||
class StorelocationAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
|
@ -38,27 +41,27 @@ class StorelocationAdminForm extends BaseEntityAdminForm
|
|||
'label' => 'storelocation.edit.is_full.label',
|
||||
'help' => 'storelocation.edit.is_full.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
|
||||
$builder->add('limit_to_existing_parts', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'storelocation.limit_to_existing.label',
|
||||
'help' => 'storelocation.limit_to_existing.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
|
||||
$builder->add('only_single_part', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label' => 'storelocation.only_single_part.label',
|
||||
'help' => 'storelocation.only_single_part.help',
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
|
||||
$builder->add('storage_type', StructuralEntityType::class, [
|
||||
'required' => false,
|
||||
'label' => 'storelocation.storage_type.label',
|
||||
'help' => 'storelocation.storage_type.help',
|
||||
'class' => MeasurementUnit::class, 'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -29,7 +32,7 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||
|
||||
class SupplierForm extends CompanyForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
$is_new = null === $entity->getID();
|
||||
|
||||
|
@ -40,14 +43,14 @@ class SupplierForm extends CompanyForm
|
|||
'required' => false,
|
||||
'label' => 'supplier.edit.default_currency',
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity), ]);
|
||||
|
||||
$builder->add('shipping_costs', MoneyType::class, [
|
||||
'required' => false,
|
||||
'currency' => $this->params->get('default_currency'),
|
||||
'scale' => 3,
|
||||
'label' => 'supplier.shipping_costs.label',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'move', $entity),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -53,7 +56,7 @@ class AttachmentFormType extends AbstractType
|
|||
$this->allow_attachments_download = $allow_attachments_downloads;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder->add('name', TextType::class, [
|
||||
'label' => 'attachment.edit.name',
|
||||
|
@ -94,7 +97,7 @@ class AttachmentFormType extends AbstractType
|
|||
$builder->add('downloadURL', CheckboxType::class, ['required' => false,
|
||||
'label' => 'attachment.edit.download_url',
|
||||
'mapped' => false,
|
||||
'disabled' => !$this->allow_attachments_download,
|
||||
'disabled' => ! $this->allow_attachments_download,
|
||||
'attr' => ['class' => 'form-control-sm'],
|
||||
'label_attr' => ['class' => 'checkbox-custom'], ]);
|
||||
|
||||
|
@ -114,7 +117,7 @@ class AttachmentFormType extends AbstractType
|
|||
//Check the secure file checkbox, if file is in securefile location
|
||||
$builder->get('secureFile')->addEventListener(
|
||||
FormEvents::PRE_SET_DATA,
|
||||
function (FormEvent $event) {
|
||||
function (FormEvent $event): void {
|
||||
$attachment = $event->getForm()->getParent()->getData();
|
||||
if ($attachment instanceof Attachment) {
|
||||
$event->setData($attachment->isSecure());
|
||||
|
@ -123,7 +126,7 @@ class AttachmentFormType extends AbstractType
|
|||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Attachment::class,
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -46,7 +49,7 @@ class OrderdetailType extends AbstractType
|
|||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
/** @var Orderdetail $orderdetail */
|
||||
$orderdetail = $builder->getData();
|
||||
|
@ -76,7 +79,7 @@ class OrderdetailType extends AbstractType
|
|||
]);
|
||||
|
||||
//Add pricedetails after we know the data, so we can set the default currency
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options): void {
|
||||
/** @var Orderdetail $orderdetail */
|
||||
$orderdetail = $event->getData();
|
||||
|
||||
|
@ -94,14 +97,14 @@ class OrderdetailType extends AbstractType
|
|||
'prototype_data' => $dummy_pricedetail,
|
||||
'by_reference' => false,
|
||||
'entry_options' => [
|
||||
'disabled' => !$this->security->isGranted('@parts_prices.edit'),
|
||||
'disabled' => ! $this->security->isGranted('@parts_prices.edit'),
|
||||
'measurement_unit' => $options['measurement_unit'],
|
||||
],
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Orderdetail::class,
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -59,7 +62,7 @@ class PartBaseType extends AbstractType
|
|||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
/** @var Part $part */
|
||||
$part = $builder->getData();
|
||||
|
@ -79,7 +82,7 @@ class PartBaseType extends AbstractType
|
|||
'empty_data' => '',
|
||||
'label' => 'part.edit.name',
|
||||
'attr' => ['placeholder' => 'part.edit.name.placeholder'],
|
||||
'disabled' => !$this->security->isGranted('name.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('name.edit', $part),
|
||||
])
|
||||
->add('description', CKEditorType::class, [
|
||||
'required' => false,
|
||||
|
@ -87,26 +90,26 @@ class PartBaseType extends AbstractType
|
|||
'label' => 'part.edit.description',
|
||||
'config_name' => 'description_config',
|
||||
'attr' => ['placeholder' => 'part.edit.description.placeholder', 'rows' => 2],
|
||||
'disabled' => !$this->security->isGranted('description.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('description.edit', $part),
|
||||
])
|
||||
->add('minAmount', SIUnitType::class, [
|
||||
'attr' => ['min' => 0, 'placeholder' => 'part.editmininstock.placeholder'],
|
||||
'label' => 'part.edit.mininstock',
|
||||
'measurement_unit' => $part->getPartUnit(),
|
||||
'disabled' => !$this->security->isGranted('minamount.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('minamount.edit', $part),
|
||||
])
|
||||
->add('category', StructuralEntityType::class, [
|
||||
'class' => Category::class,
|
||||
'label' => 'part.edit.category',
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted('category.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('category.edit', $part),
|
||||
])
|
||||
->add('footprint', StructuralEntityType::class, [
|
||||
'class' => Footprint::class,
|
||||
'required' => false,
|
||||
'label' => 'part.edit.footprint',
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted('footprint.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('footprint.edit', $part),
|
||||
])
|
||||
->add('tags', TextType::class, [
|
||||
'required' => false,
|
||||
|
@ -115,7 +118,7 @@ class PartBaseType extends AbstractType
|
|||
'attr' => [
|
||||
'class' => 'tagsinput',
|
||||
'data-autocomplete' => $this->urlGenerator->generate('typeahead_tags', ['query' => 'QUERY']), ],
|
||||
'disabled' => !$this->security->isGranted('tags.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('tags.edit', $part),
|
||||
]);
|
||||
|
||||
//Manufacturer section
|
||||
|
@ -124,24 +127,24 @@ class PartBaseType extends AbstractType
|
|||
'required' => false,
|
||||
'label' => 'part.edit.manufacturer.label',
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted('manufacturer.edit', $part),
|
||||
])
|
||||
'disabled' => ! $this->security->isGranted('manufacturer.edit', $part),
|
||||
])
|
||||
->add('manufacturer_product_url', UrlType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'part.edit.manufacturer_url.label',
|
||||
'disabled' => !$this->security->isGranted('mpn.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('mpn.edit', $part),
|
||||
])
|
||||
->add('manufacturer_product_number', TextType::class, [
|
||||
'required' => false,
|
||||
'empty_data' => '',
|
||||
'label' => 'part.edit.mpn',
|
||||
'disabled' => !$this->security->isGranted('mpn.edit', $part), ])
|
||||
'disabled' => ! $this->security->isGranted('mpn.edit', $part), ])
|
||||
->add('manufacturing_status', ChoiceType::class, [
|
||||
'label' => 'part.edit.manufacturing_status',
|
||||
'choices' => $status_choices,
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('status.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('status.edit', $part),
|
||||
]);
|
||||
|
||||
//Advanced section
|
||||
|
@ -149,26 +152,26 @@ class PartBaseType extends AbstractType
|
|||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'required' => false,
|
||||
'label' => 'part.edit.needs_review',
|
||||
'disabled' => !$this->security->isGranted('edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('edit', $part),
|
||||
])
|
||||
->add('favorite', CheckboxType::class, [
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'required' => false,
|
||||
'label' => 'part.edit.is_favorite',
|
||||
'disabled' => !$this->security->isGranted('change_favorite', $part),
|
||||
'disabled' => ! $this->security->isGranted('change_favorite', $part),
|
||||
])
|
||||
->add('mass', SIUnitType::class, [
|
||||
'unit' => 'g',
|
||||
'label' => 'part.edit.mass',
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('mass.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('mass.edit', $part),
|
||||
])
|
||||
->add('partUnit', StructuralEntityType::class, [
|
||||
'class' => MeasurementUnit::class,
|
||||
'required' => false,
|
||||
'disable_not_selectable' => true,
|
||||
'label' => 'part.edit.partUnit',
|
||||
'disabled' => !$this->security->isGranted('unit.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('unit.edit', $part),
|
||||
]);
|
||||
|
||||
//Comment section
|
||||
|
@ -176,7 +179,7 @@ class PartBaseType extends AbstractType
|
|||
'required' => false,
|
||||
'label' => 'part.edit.comment',
|
||||
'attr' => ['rows' => 4],
|
||||
'disabled' => !$this->security->isGranted('comment.edit', $part), 'empty_data' => '',
|
||||
'disabled' => ! $this->security->isGranted('comment.edit', $part), 'empty_data' => '',
|
||||
]);
|
||||
|
||||
//Part Lots section
|
||||
|
@ -187,7 +190,7 @@ class PartBaseType extends AbstractType
|
|||
'label' => false,
|
||||
'entry_options' => [
|
||||
'measurement_unit' => $part->getPartUnit(),
|
||||
'disabled' => !$this->security->isGranted('lots.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('lots.edit', $part),
|
||||
],
|
||||
'by_reference' => false,
|
||||
]);
|
||||
|
@ -200,14 +203,14 @@ class PartBaseType extends AbstractType
|
|||
'label' => false,
|
||||
'entry_options' => [
|
||||
'data_class' => PartAttachment::class,
|
||||
'disabled' => !$this->security->isGranted('attachments.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('attachments.edit', $part),
|
||||
],
|
||||
'by_reference' => false,
|
||||
]);
|
||||
|
||||
$builder->add('master_picture_attachment', MasterPictureAttachmentType::class, [
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('attachments.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('attachments.edit', $part),
|
||||
'label' => 'part.edit.master_attachment',
|
||||
'entity' => $part,
|
||||
]);
|
||||
|
@ -222,7 +225,7 @@ class PartBaseType extends AbstractType
|
|||
'prototype_data' => new Orderdetail(),
|
||||
'entry_options' => [
|
||||
'measurement_unit' => $part->getPartUnit(),
|
||||
'disabled' => !$this->security->isGranted('orderdetails.edit', $part),
|
||||
'disabled' => ! $this->security->isGranted('orderdetails.edit', $part),
|
||||
],
|
||||
]);
|
||||
|
||||
|
@ -232,7 +235,7 @@ class PartBaseType extends AbstractType
|
|||
->add('reset', ResetType::class, ['label' => 'part.edit.reset']);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Part::class,
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -43,7 +46,7 @@ class PartLotType extends AbstractType
|
|||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder->add('description', TextType::class, [
|
||||
'label' => 'part_lot.edit.description',
|
||||
|
@ -89,7 +92,7 @@ class PartLotType extends AbstractType
|
|||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => PartLot::class,
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -32,7 +35,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
|
||||
class PricedetailType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
//No labels needed, we define translation in templates
|
||||
$builder->add('min_discount_quantity', SIUnitType::class, [
|
||||
|
@ -57,7 +60,7 @@ class PricedetailType extends AbstractType
|
|||
]);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Pricedetail::class,
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -38,7 +41,7 @@ class PermissionGroupType extends AbstractType
|
|||
$this->perm_structure = $resolver->getPermissionStructure();
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$permissions = $this->perm_structure['perms'];
|
||||
|
||||
|
@ -66,7 +69,7 @@ class PermissionGroupType extends AbstractType
|
|||
}
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
|
||||
|
@ -77,7 +80,7 @@ class PermissionGroupType extends AbstractType
|
|||
$resolver->setDefault('inherit', false);
|
||||
|
||||
$resolver->setDefault('label', function (Options $options) {
|
||||
if (!empty($this->perm_structure['groups'][$options['group_name']]['label'])) {
|
||||
if (! empty($this->perm_structure['groups'][$options['group_name']]['label'])) {
|
||||
return $this->perm_structure['groups'][$options['group_name']]['label'];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -41,7 +44,7 @@ class PermissionType extends AbstractType
|
|||
$this->perm_structure = $resolver->getPermissionStructure();
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
parent::configureOptions($resolver);
|
||||
|
||||
|
@ -50,7 +53,7 @@ class PermissionType extends AbstractType
|
|||
});
|
||||
|
||||
$resolver->setDefault('label', function (Options $options) {
|
||||
if (!empty($this->perm_structure['perms'][$options['perm_name']]['label'])) {
|
||||
if (! empty($this->perm_structure['perms'][$options['perm_name']]['label'])) {
|
||||
return $this->perm_structure['perms'][$options['perm_name']]['label'];
|
||||
}
|
||||
|
||||
|
@ -58,7 +61,7 @@ class PermissionType extends AbstractType
|
|||
});
|
||||
|
||||
$resolver->setDefault('multi_checkbox', function (Options $options) {
|
||||
return !$options['disabled'];
|
||||
return ! $options['disabled'];
|
||||
});
|
||||
|
||||
$resolver->setDefaults([
|
||||
|
@ -66,7 +69,7 @@ class PermissionType extends AbstractType
|
|||
]);
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$operations = $this->perm_structure['perms'][$options['perm_name']]['operations'];
|
||||
|
||||
|
@ -82,7 +85,7 @@ class PermissionType extends AbstractType
|
|||
$builder->setDataMapper(new PermissionsMapper($this->resolver, $options['inherit']));
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
$view->vars['multi_checkbox'] = $options['multi_checkbox'];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -49,7 +52,7 @@ class PermissionsMapper implements DataMapperInterface
|
|||
* @param mixed $viewData View data of the compound form being initialized
|
||||
* @param FormInterface[]|\Traversable $forms A list of {@link FormInterface} instances
|
||||
*/
|
||||
public function mapDataToForms($viewData, $forms)
|
||||
public function mapDataToForms($viewData, $forms): void
|
||||
{
|
||||
foreach ($forms as $form) {
|
||||
if ($this->inherit) {
|
||||
|
@ -96,7 +99,7 @@ class PermissionsMapper implements DataMapperInterface
|
|||
* @param mixed $viewData The compound form's view data that get mapped
|
||||
* its children model data
|
||||
*/
|
||||
public function mapFormsToData($forms, &$viewData)
|
||||
public function mapFormsToData($forms, &$viewData): void
|
||||
{
|
||||
if ($this->inherit) {
|
||||
throw new \RuntimeException('The permission type is readonly when it is showing read only data!');
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -41,12 +44,12 @@ class PermissionsType extends AbstractType
|
|||
$this->perm_structure = $resolver->getPermissionStructure();
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'show_legend' => true,
|
||||
'constraints' => function (Options $options) {
|
||||
if (!$options['disabled']) {
|
||||
if (! $options['disabled']) {
|
||||
return [new NoLockout()];
|
||||
}
|
||||
|
||||
|
@ -56,12 +59,12 @@ class PermissionsType extends AbstractType
|
|||
]);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
$view->vars['show_legend'] = $options['show_legend'];
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$groups = $this->perm_structure['groups'];
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -41,15 +44,15 @@ class TFAGoogleSettingsType extends AbstractType
|
|||
{
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
|
||||
$form = $event->getForm();
|
||||
/** @var User $user */
|
||||
$user = $event->getData();
|
||||
|
||||
//Only show setup fields, when google authenticator is not enabled
|
||||
if (!$user->isGoogleAuthenticatorEnabled()) {
|
||||
if (! $user->isGoogleAuthenticatorEnabled()) {
|
||||
$form->add(
|
||||
'google_confirmation',
|
||||
TextType::class,
|
||||
|
@ -82,10 +85,10 @@ class TFAGoogleSettingsType extends AbstractType
|
|||
//$builder->add('cancel', ResetType::class);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
'data_class' => User::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -39,7 +42,7 @@ class CurrencyEntityType extends StructuralEntityType
|
|||
$this->base_currency = $base_currency;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
//Important to call the parent resolver!
|
||||
parent::configureOptions($resolver);
|
||||
|
@ -91,7 +94,7 @@ class CurrencyEntityType extends StructuralEntityType
|
|||
/** @var Currency $choice */
|
||||
$tmp = [];
|
||||
|
||||
if (!empty($choice->getIsoCode())) {
|
||||
if (! empty($choice->getIsoCode())) {
|
||||
//Show the name of the currency
|
||||
$tmp += ['data-subtext' => $choice->getName()];
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -31,7 +34,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
|||
|
||||
class MasterPictureAttachmentType extends AbstractType
|
||||
{
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setRequired('entity');
|
||||
$resolver->setAllowedTypes('entity', AttachmentContainingDBElement::class);
|
||||
|
@ -44,9 +47,9 @@ class MasterPictureAttachmentType extends AbstractType
|
|||
/** @var Attachment $choice */
|
||||
$tmp = ['data-subtext' => $choice->getFilename() ?? 'URL'];
|
||||
|
||||
if ('picture' === $options['filter'] && !$choice->isPicture()) {
|
||||
if ('picture' === $options['filter'] && ! $choice->isPicture()) {
|
||||
$tmp += ['disabled' => 'disabled'];
|
||||
} elseif ('3d_model' === $options['filter'] && !$choice->is3DModel()) {
|
||||
} elseif ('3d_model' === $options['filter'] && ! $choice->is3DModel()) {
|
||||
$tmp += ['disabled' => 'disabled'];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -43,7 +46,7 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
$this->si_formatter = $SIFormatter;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'measurement_unit' => null,
|
||||
|
@ -85,20 +88,20 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
|
||||
//Options which allows us, to limit the input using HTML5 number input
|
||||
$resolver->setDefaults([
|
||||
'min' => 0,
|
||||
'max' => '',
|
||||
'step' => function (Options $options) {
|
||||
if (true === $options['is_integer']) {
|
||||
return 1;
|
||||
}
|
||||
'min' => 0,
|
||||
'max' => '',
|
||||
'step' => function (Options $options) {
|
||||
if (true === $options['is_integer']) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 'any';
|
||||
},
|
||||
'html5' => true,
|
||||
]);
|
||||
return 'any';
|
||||
},
|
||||
'html5' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('value', NumberType::class, [
|
||||
|
@ -121,13 +124,13 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
$builder->setDataMapper($this);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
$view->vars['sm'] = false;
|
||||
|
||||
//Check if we need to make this thing small
|
||||
if (isset($options['attr']['class'])) {
|
||||
$view->vars['sm'] = (false !== strpos($options['attr']['class'], 'form-control-sm'));
|
||||
$view->vars['sm'] = false !== strpos($options['attr']['class'], 'form-control-sm');
|
||||
}
|
||||
|
||||
$view->vars['unit'] = $options['unit'];
|
||||
|
@ -196,7 +199,7 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
*
|
||||
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
|
||||
*/
|
||||
public function mapFormsToData($forms, &$viewData)
|
||||
public function mapFormsToData($forms, &$viewData): void
|
||||
{
|
||||
//Convert both fields to a single float value.
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -56,7 +59,7 @@ class StructuralEntityType extends AbstractType
|
|||
$this->builder = $builder;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder->addModelTransformer(new CallbackTransformer(
|
||||
function ($value) use ($options) {
|
||||
|
@ -66,7 +69,7 @@ class StructuralEntityType extends AbstractType
|
|||
}));
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setRequired(['class']);
|
||||
$resolver->setDefaults([
|
||||
|
@ -97,44 +100,6 @@ class StructuralEntityType extends AbstractType
|
|||
});
|
||||
}
|
||||
|
||||
protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value): array
|
||||
{
|
||||
$tmp = [];
|
||||
|
||||
if ($this->options['show_fullpath_in_subtext'] && null != $choice->getParent()) {
|
||||
$tmp += ['data-subtext' => $choice->getParent()->getFullPath()];
|
||||
}
|
||||
|
||||
//Disable attribute if the choice is marked as not selectable
|
||||
if ($this->options['disable_not_selectable'] && $choice->isNotSelectable()) {
|
||||
$tmp += ['disabled' => 'disabled'];
|
||||
}
|
||||
|
||||
if ($choice instanceof AttachmentType) {
|
||||
$tmp += ['data-filetype_filter' => $choice->getFiletypeFilter()];
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function generateChoiceLabels(StructuralDBElement $choice, $key, $value): string
|
||||
{
|
||||
/** @var StructuralDBElement|null $parent */
|
||||
$parent = $this->options['subentities_of'];
|
||||
|
||||
/*** @var StructuralDBElement $choice */
|
||||
$level = $choice->getLevel();
|
||||
//If our base entity is not the root level, we need to change the level, to get zero position
|
||||
if (null !== $this->options['subentities_of']) {
|
||||
$level -= $parent->getLevel() - 1;
|
||||
}
|
||||
|
||||
$tmp = str_repeat(' ', $choice->getLevel()); //Use 3 spaces for intendation
|
||||
$tmp .= htmlspecialchars($choice->getName());
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entries from database and return an array of them.
|
||||
*
|
||||
|
@ -144,15 +109,10 @@ class StructuralEntityType extends AbstractType
|
|||
{
|
||||
$this->options = $options;
|
||||
|
||||
$choices = $this->builder->typeToNodesList($options['class'], null);
|
||||
|
||||
/* @var StructuralDBElementRepository $repo */
|
||||
/*$repo = $this->em->getRepository($options['class']);
|
||||
$choices = $repo->toNodesList(null); */
|
||||
return $choices;
|
||||
return $this->builder->typeToNodesList($options['class'], null);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
//Allow HTML in labels. You must override the 'choice_widget_options' block, so that can work
|
||||
//See extendedBootstrap4_layout.html.twig for that...
|
||||
|
@ -253,4 +213,42 @@ class StructuralEntityType extends AbstractType
|
|||
|
||||
return $this->em->find($options['class'], $value->getID());
|
||||
}
|
||||
|
||||
protected function generateChoiceAttr(StructuralDBElement $choice, $key, $value): array
|
||||
{
|
||||
$tmp = [];
|
||||
|
||||
if ($this->options['show_fullpath_in_subtext'] && null !== $choice->getParent()) {
|
||||
$tmp += ['data-subtext' => $choice->getParent()->getFullPath()];
|
||||
}
|
||||
|
||||
//Disable attribute if the choice is marked as not selectable
|
||||
if ($this->options['disable_not_selectable'] && $choice->isNotSelectable()) {
|
||||
$tmp += ['disabled' => 'disabled'];
|
||||
}
|
||||
|
||||
if ($choice instanceof AttachmentType) {
|
||||
$tmp += ['data-filetype_filter' => $choice->getFiletypeFilter()];
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
protected function generateChoiceLabels(StructuralDBElement $choice, $key, $value): string
|
||||
{
|
||||
/** @var StructuralDBElement|null $parent */
|
||||
$parent = $this->options['subentities_of'];
|
||||
|
||||
/*** @var StructuralDBElement $choice */
|
||||
$level = $choice->getLevel();
|
||||
//If our base entity is not the root level, we need to change the level, to get zero position
|
||||
if (null !== $this->options['subentities_of']) {
|
||||
$level -= $parent->getLevel() - 1;
|
||||
}
|
||||
|
||||
$tmp = str_repeat(' ', $choice->getLevel()); //Use 3 spaces for intendation
|
||||
$tmp .= htmlspecialchars($choice->getName());
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -36,7 +39,7 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
|
|||
$builder->addViewTransformer($this);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'label_attr' => ['class' => 'checkbox-custom checkbox-inline'],
|
||||
|
@ -50,10 +53,7 @@ class TriStateCheckboxType extends AbstractType implements DataTransformerInterf
|
|||
return 'tristate';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
$view->vars = array_replace($view->vars, [
|
||||
'value' => $form->getViewData(),
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -54,13 +57,13 @@ class UserAdminForm extends AbstractType
|
|||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
parent::configureOptions($resolver); // TODO: Change the autogenerated stub
|
||||
$resolver->setRequired('attachment_class');
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
/** @var StructuralDBElement $entity */
|
||||
$entity = $options['data'];
|
||||
|
@ -71,7 +74,7 @@ class UserAdminForm extends AbstractType
|
|||
'empty_data' => '',
|
||||
'label' => 'user.username.label',
|
||||
'attr' => ['placeholder' => 'user.username.placeholder'],
|
||||
'disabled' => !$this->security->isGranted('edit_username', $entity),
|
||||
'disabled' => ! $this->security->isGranted('edit_username', $entity),
|
||||
])
|
||||
|
||||
->add('group', StructuralEntityType::class, [
|
||||
|
@ -79,13 +82,13 @@ class UserAdminForm extends AbstractType
|
|||
'required' => false,
|
||||
'label' => 'group.label',
|
||||
'disable_not_selectable' => true,
|
||||
'disabled' => !$this->security->isGranted('change_group', $entity), ])
|
||||
'disabled' => ! $this->security->isGranted('change_group', $entity), ])
|
||||
|
||||
->add('first_name', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'user.firstName.label',
|
||||
'attr' => ['placeholder' => 'user.firstName.placeholder'], 'required' => false,
|
||||
'disabled' => !$this->security->isGranted('edit_infos', $entity),
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $entity),
|
||||
])
|
||||
|
||||
->add('last_name', TextType::class, [
|
||||
|
@ -93,7 +96,7 @@ class UserAdminForm extends AbstractType
|
|||
'label' => 'user.lastName.label',
|
||||
'attr' => ['placeholder' => 'user.lastName.placeholder'],
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('edit_infos', $entity),
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $entity),
|
||||
])
|
||||
|
||||
->add('email', TextType::class, [
|
||||
|
@ -101,14 +104,14 @@ class UserAdminForm extends AbstractType
|
|||
'label' => 'user.email.label',
|
||||
'attr' => ['placeholder' => 'user.email.placeholder'],
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('edit_infos', $entity), ])
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $entity), ])
|
||||
|
||||
->add('department', TextType::class, [
|
||||
'empty_data' => '',
|
||||
'label' => 'user.department.label',
|
||||
'attr' => ['placeholder' => 'user.department.placeholder'],
|
||||
'required' => false,
|
||||
'disabled' => !$this->security->isGranted('edit_infos', $entity),
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $entity),
|
||||
])
|
||||
|
||||
//Config section
|
||||
|
@ -118,7 +121,7 @@ class UserAdminForm extends AbstractType
|
|||
'placeholder' => 'user_settings.language.placeholder',
|
||||
'label' => 'user.language_select',
|
||||
'preferred_choices' => ['en', 'de'],
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
||||
'disabled' => ! $this->security->isGranted('change_user_settings', $entity),
|
||||
])
|
||||
->add('timezone', TimezoneType::class, [
|
||||
'required' => false,
|
||||
|
@ -126,7 +129,7 @@ class UserAdminForm extends AbstractType
|
|||
'placeholder' => 'user_settings.timezone.placeholder',
|
||||
'label' => 'user.timezone.label',
|
||||
'preferred_choices' => ['Europe/Berlin'],
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
||||
'disabled' => ! $this->security->isGranted('change_user_settings', $entity),
|
||||
])
|
||||
->add('theme', ChoiceType::class, [
|
||||
'required' => false,
|
||||
|
@ -137,12 +140,12 @@ class UserAdminForm extends AbstractType
|
|||
'attr' => ['class' => 'selectpicker'],
|
||||
'placeholder' => 'user_settings.theme.placeholder',
|
||||
'label' => 'user.theme.label',
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
||||
'disabled' => ! $this->security->isGranted('change_user_settings', $entity),
|
||||
])
|
||||
->add('currency', CurrencyEntityType::class, [
|
||||
'required' => false,
|
||||
'label' => 'user.currency.label',
|
||||
'disabled' => !$this->security->isGranted('change_user_settings', $entity),
|
||||
'disabled' => ! $this->security->isGranted('change_user_settings', $entity),
|
||||
])
|
||||
|
||||
->add('new_password', RepeatedType::class, [
|
||||
|
@ -152,7 +155,7 @@ class UserAdminForm extends AbstractType
|
|||
'invalid_message' => 'password_must_match',
|
||||
'required' => false,
|
||||
'mapped' => false,
|
||||
'disabled' => !$this->security->isGranted('set_password', $entity),
|
||||
'disabled' => ! $this->security->isGranted('set_password', $entity),
|
||||
'constraints' => [new Length([
|
||||
'min' => 6,
|
||||
'max' => 128,
|
||||
|
@ -163,14 +166,14 @@ class UserAdminForm extends AbstractType
|
|||
'required' => false,
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label' => 'user.edit.needs_pw_change',
|
||||
'disabled' => !$this->security->isGranted('set_password', $entity),
|
||||
'disabled' => ! $this->security->isGranted('set_password', $entity),
|
||||
])
|
||||
|
||||
->add('disabled', CheckboxType::class, [
|
||||
'required' => false,
|
||||
'label_attr' => ['class' => 'checkbox-custom'],
|
||||
'label' => 'user.edit.user_disabled',
|
||||
'disabled' => !$this->security->isGranted('set_password', $entity)
|
||||
'disabled' => ! $this->security->isGranted('set_password', $entity)
|
||||
|| $entity === $this->security->getUser(),
|
||||
])
|
||||
|
||||
|
@ -178,7 +181,7 @@ class UserAdminForm extends AbstractType
|
|||
->add('permissions', PermissionsType::class, [
|
||||
'mapped' => false,
|
||||
'data' => $builder->getData(),
|
||||
'disabled' => !$this->security->isGranted('edit_permissions', $entity),
|
||||
'disabled' => ! $this->security->isGranted('edit_permissions', $entity),
|
||||
])
|
||||
;
|
||||
/*->add('comment', CKEditorType::class, ['required' => false,
|
||||
|
@ -197,7 +200,7 @@ class UserAdminForm extends AbstractType
|
|||
'data_class' => $options['attachment_class'],
|
||||
],
|
||||
'by_reference' => false,
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
'disabled' => ! $this->security->isGranted($is_new ? 'create' : 'edit', $entity),
|
||||
]);
|
||||
|
||||
//Buttons
|
||||
|
@ -210,7 +213,7 @@ class UserAdminForm extends AbstractType
|
|||
]);
|
||||
}
|
||||
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity): void
|
||||
{
|
||||
//Empty for Base
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -46,32 +49,32 @@ class UserSettingsType extends AbstractType
|
|||
$this->demo_mode = $demo_mode;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'user.username.label',
|
||||
'disabled' => !$this->security->isGranted('edit_username', $options['data']) || $this->demo_mode,
|
||||
'disabled' => ! $this->security->isGranted('edit_username', $options['data']) || $this->demo_mode,
|
||||
])
|
||||
->add('first_name', TextType::class, [
|
||||
'required' => false,
|
||||
'label' => 'user.firstName.label',
|
||||
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
||||
])
|
||||
->add('last_name', TextType::class, [
|
||||
'required' => false,
|
||||
'label' => 'user.lastName.label',
|
||||
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
||||
])
|
||||
->add('department', TextType::class, [
|
||||
'required' => false,
|
||||
'label' => 'user.department.label',
|
||||
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
||||
])
|
||||
->add('email', EmailType::class, [
|
||||
'required' => false,
|
||||
'label' => 'user.email.label',
|
||||
'disabled' => !$this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
||||
'disabled' => ! $this->security->isGranted('edit_infos', $options['data']) || $this->demo_mode,
|
||||
])
|
||||
->add('language', LanguageType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
|
@ -80,7 +83,7 @@ class UserSettingsType extends AbstractType
|
|||
'placeholder' => 'user_settings.language.placeholder',
|
||||
'label' => 'user.language_select',
|
||||
'preferred_choices' => ['en', 'de'],
|
||||
])
|
||||
])
|
||||
->add('timezone', TimezoneType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
'required' => false,
|
||||
|
@ -88,7 +91,7 @@ class UserSettingsType extends AbstractType
|
|||
'placeholder' => 'user_settings.timezone.placeholder',
|
||||
'label' => 'user.timezone.label',
|
||||
'preferred_choices' => ['Europe/Berlin'],
|
||||
])
|
||||
])
|
||||
->add('theme', ChoiceType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
'required' => false,
|
||||
|
@ -99,7 +102,7 @@ class UserSettingsType extends AbstractType
|
|||
},
|
||||
'placeholder' => 'user_settings.theme.placeholder',
|
||||
'label' => 'user.theme.label',
|
||||
])
|
||||
])
|
||||
->add('currency', CurrencyEntityType::class, [
|
||||
'disabled' => $this->demo_mode,
|
||||
'required' => false,
|
||||
|
@ -111,7 +114,7 @@ class UserSettingsType extends AbstractType
|
|||
->add('reset', ResetType::class, ['label' => 'reset']);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => User::class,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue