mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-20 19:05:14 +02:00
Fixed some inspection issues.
This commit is contained in:
parent
6caf605fe2
commit
e01b06fb85
80 changed files with 173 additions and 218 deletions
|
@ -76,7 +76,7 @@ class AttachmentTypeAdminForm extends BaseEntityAdminForm
|
|||
|
||||
//Normalize data before writing it to database
|
||||
$builder->get('filetype_filter')->addViewTransformer(new CallbackTransformer(
|
||||
function ($value) {
|
||||
static function ($value) {
|
||||
return $value;
|
||||
},
|
||||
function ($value) {
|
||||
|
|
|
@ -176,19 +176,18 @@ class AttachmentFormType extends AbstractType
|
|||
$file_form = $form->get('file');
|
||||
$file = $file_form->getData();
|
||||
|
||||
if ($attachment instanceof Attachment && $file instanceof UploadedFile && $attachment->getAttachmentType()) {
|
||||
if (!$this->submitHandler->isValidFileExtension($attachment->getAttachmentType(), $file)) {
|
||||
if ($attachment instanceof Attachment && $file instanceof UploadedFile && $attachment->getAttachmentType(
|
||||
) && !$this->submitHandler->isValidFileExtension($attachment->getAttachmentType(), $file)) {
|
||||
$event->getForm()->get('file')->addError(
|
||||
new FormError($this->translator->trans('validator.file_ext_not_allowed'))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//Check the secure file checkbox, if file is in securefile location
|
||||
$builder->get('secureFile')->addEventListener(
|
||||
FormEvents::PRE_SET_DATA,
|
||||
function (FormEvent $event): void {
|
||||
static function (FormEvent $event): void {
|
||||
$attachment = $event->getForm()->getParent()->getData();
|
||||
if ($attachment instanceof Attachment) {
|
||||
$event->setData($attachment->isSecure());
|
||||
|
|
|
@ -32,7 +32,6 @@ use Symfony\Component\Form\FormBuilderInterface;
|
|||
use Symfony\Component\Form\FormConfigBuilder;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ class LabelOptionsType extends AbstractType
|
|||
'label_options.barcode_type.code93' => 'code93',
|
||||
'label_options.barcode_type.datamatrix' => 'datamatrix',
|
||||
],
|
||||
'group_by' => function ($choice, $key, $value) {
|
||||
'group_by' => static function ($choice, $key, $value) {
|
||||
if (in_array($choice, ['qr', 'datamatrix'], true)) {
|
||||
return 'label_options.barcode_type.2D';
|
||||
}
|
||||
|
|
|
@ -42,7 +42,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Form\Part;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Attachments\PartAttachment;
|
||||
use App\Entity\Parameters\PartParameter;
|
||||
use App\Entity\Parts\Category;
|
||||
|
|
|
@ -69,11 +69,8 @@ class PermissionGroupType extends AbstractType
|
|||
if ($permission['group'] !== $options['group_name']) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
//Skip perrmissions without groups unless we have this as blanko group
|
||||
if ('*' !== $options['group_name']) {
|
||||
continue;
|
||||
}
|
||||
} elseif ('*' !== $options['group_name']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$builder->add($key, PermissionType::class, [
|
||||
|
@ -91,7 +88,7 @@ class PermissionGroupType extends AbstractType
|
|||
{
|
||||
parent::configureOptions($resolver);
|
||||
|
||||
$resolver->setDefault('group_name', function (Options $options) {
|
||||
$resolver->setDefault('group_name', static function (Options $options) {
|
||||
return trim($options['name']);
|
||||
});
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ class PermissionType extends AbstractType
|
|||
{
|
||||
parent::configureOptions($resolver);
|
||||
|
||||
$resolver->setDefault('perm_name', function (Options $options) {
|
||||
$resolver->setDefault('perm_name', static function (Options $options) {
|
||||
return $options['name'];
|
||||
});
|
||||
|
||||
|
@ -78,7 +78,7 @@ class PermissionType extends AbstractType
|
|||
return $options['name'];
|
||||
});
|
||||
|
||||
$resolver->setDefault('multi_checkbox', function (Options $options) {
|
||||
$resolver->setDefault('multi_checkbox', static function (Options $options) {
|
||||
return !$options['disabled'];
|
||||
});
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ final 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): void
|
||||
public function mapDataToForms($viewData, $forms)
|
||||
{
|
||||
foreach ($forms as $form) {
|
||||
if ($this->inherit) {
|
||||
|
@ -119,7 +119,7 @@ final 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): void
|
||||
public function mapFormsToData($forms, &$viewData) :void
|
||||
{
|
||||
if ($this->inherit) {
|
||||
throw new RuntimeException('The permission type is readonly when it is showing read only data!');
|
||||
|
|
|
@ -66,7 +66,7 @@ class PermissionsType extends AbstractType
|
|||
{
|
||||
$resolver->setDefaults([
|
||||
'show_legend' => true,
|
||||
'constraints' => function (Options $options) {
|
||||
'constraints' => static function (Options $options) {
|
||||
if (!$options['disabled']) {
|
||||
return [new NoLockout()];
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ use App\Entity\UserSystem\User;
|
|||
use App\Validator\Constraints\ValidGoogleAuthCode;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@ -64,7 +63,7 @@ class TFAGoogleSettingsType extends AbstractType
|
|||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event): void {
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, static function (FormEvent $event): void {
|
||||
$form = $event->getForm();
|
||||
/** @var User $user */
|
||||
$user = $event->getData();
|
||||
|
|
|
@ -65,8 +65,8 @@ class MasterPictureAttachmentType extends AbstractType
|
|||
'class' => 'selectpicker',
|
||||
'title' => 'selectpicker.nothing_selected',
|
||||
],
|
||||
'choice_attr' => function (Options $options) {
|
||||
return function ($choice, $key, $value) use ($options) {
|
||||
'choice_attr' => static function (Options $options) {
|
||||
return static function ($choice, $key, $value) use ($options) {
|
||||
/** @var Attachment $choice */
|
||||
$tmp = ['data-subtext' => $choice->getFilename() ?? 'URL'];
|
||||
|
||||
|
@ -80,8 +80,9 @@ class MasterPictureAttachmentType extends AbstractType
|
|||
};
|
||||
},
|
||||
'choice_label' => 'name',
|
||||
'choice_loader' => function (Options $options) {
|
||||
return new CallbackChoiceLoader(function () use ($options) {
|
||||
'choice_loader' => static function (Options $options) {
|
||||
return new CallbackChoiceLoader(
|
||||
static function () use ($options) {
|
||||
$entity = $options['entity'];
|
||||
if (!$entity instanceof AttachmentContainingDBElement) {
|
||||
throw new \RuntimeException('$entity must have Attachments! (be of type AttachmentContainingDBElement)');
|
||||
|
|
|
@ -69,7 +69,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
{
|
||||
$resolver->setDefaults([
|
||||
'measurement_unit' => null,
|
||||
'show_prefix' => function (Options $options) {
|
||||
'show_prefix' => static function (Options $options) {
|
||||
if (null !== $options['measurement_unit']) {
|
||||
/** @var MeasurementUnit $unit */
|
||||
$unit = $options['measurement_unit'];
|
||||
|
@ -79,7 +79,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
|
||||
return false;
|
||||
},
|
||||
'is_integer' => function (Options $options) {
|
||||
'is_integer' => static function (Options $options) {
|
||||
if (null !== $options['measurement_unit']) {
|
||||
/** @var MeasurementUnit $unit */
|
||||
$unit = $options['measurement_unit'];
|
||||
|
@ -89,7 +89,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
|
||||
return false;
|
||||
},
|
||||
'unit' => function (Options $options) {
|
||||
'unit' => static function (Options $options) {
|
||||
if (null !== $options['measurement_unit']) {
|
||||
/** @var MeasurementUnit $unit */
|
||||
$unit = $options['measurement_unit'];
|
||||
|
@ -111,7 +111,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
$resolver->setDefaults([
|
||||
'min' => 0,
|
||||
'max' => '',
|
||||
'step' => function (Options $options) {
|
||||
'step' => static function (Options $options) {
|
||||
if (true === $options['is_integer']) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ final class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
$forms['prefix']->setData(0);
|
||||
}
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
$data = $this->si_formatter->convertValue((float) $viewData);
|
||||
|
|
|
@ -44,13 +44,11 @@ namespace App\Form\Type;
|
|||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Base\AbstractStructuralDBElement;
|
||||
use App\Repository\StructuralDBElementRepository;
|
||||
use App\Services\Trees\NodesListBuilder;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\CallbackTransformer;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
|
||||
use Symfony\Component\Form\Exception;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
@ -58,7 +56,6 @@ use Symfony\Component\Form\FormInterface;
|
|||
use Symfony\Component\Form\FormView;
|
||||
use Symfony\Component\OptionsResolver\Options;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Validator\Constraints\Choice;
|
||||
|
||||
/**
|
||||
* This class provides a choice form type similar to EntityType, with the difference, that the tree structure
|
||||
|
@ -117,7 +114,7 @@ class StructuralEntityType extends AbstractType
|
|||
|
||||
$resolver->setDefault('empty_message', null);
|
||||
|
||||
$resolver->setDefault('attr', function (Options $options) {
|
||||
$resolver->setDefault('attr', static function (Options $options) {
|
||||
$tmp = [
|
||||
'class' => 'selectpicker',
|
||||
'data-live-search' => true,
|
||||
|
|
|
@ -49,7 +49,6 @@ use App\Entity\UserSystem\User;
|
|||
use App\Form\Permissions\PermissionsType;
|
||||
use App\Form\Type\CurrencyEntityType;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
@ -174,7 +173,7 @@ class UserAdminForm extends AbstractType
|
|||
->add('theme', ChoiceType::class, [
|
||||
'required' => false,
|
||||
'choices' => User::AVAILABLE_THEMES,
|
||||
'choice_label' => function ($entity, $key, $value) {
|
||||
'choice_label' => static function ($entity, $key, $value) {
|
||||
return $value;
|
||||
},
|
||||
'attr' => [
|
||||
|
|
|
@ -124,7 +124,7 @@ class UserSettingsType extends AbstractType
|
|||
],
|
||||
'choice_translation_domain' => false,
|
||||
'choices' => User::AVAILABLE_THEMES,
|
||||
'choice_label' => function ($entity, $key, $value) {
|
||||
'choice_label' => static function ($entity, $key, $value) {
|
||||
return $value;
|
||||
},
|
||||
'placeholder' => 'user_settings.theme.placeholder',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue