From f36c78428e1085b7a704c638566504b0d7f3b967 Mon Sep 17 00:00:00 2001 From: Tomasz Kryszan Date: Wed, 10 Jan 2024 11:35:42 +0100 Subject: [PATCH] IBX-7502: Moved Image asset file validation to field type definition https://issues.ibexa.co/browse/IBX-7502 --- src/lib/Form/Type/FieldType/ImageAssetFieldType.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/lib/Form/Type/FieldType/ImageAssetFieldType.php b/src/lib/Form/Type/FieldType/ImageAssetFieldType.php index 0fc17965..ce72fa1e 100644 --- a/src/lib/Form/Type/FieldType/ImageAssetFieldType.php +++ b/src/lib/Form/Type/FieldType/ImageAssetFieldType.php @@ -24,7 +24,6 @@ use Symfony\Component\Form\FormView; use Symfony\Component\Mime\MimeTypesInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Validator\Constraints as Assert; class ImageAssetFieldType extends AbstractType { @@ -79,11 +78,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) [ 'label' => /** @Desc("File") */ 'content.field_type.binary_base.file', 'required' => $options['required'], - 'constraints' => [ - new Assert\File([ - 'maxSize' => $this->getMaxFileSize(), - ]), - ], 'mapped' => false, ] ) @@ -141,12 +135,7 @@ private function getMaxFileSize(): float ->getAssetFieldDefinition() ->getValidatorConfiguration(); - $maxFileSize = $validatorConfiguration['FileSizeValidator']['maxFileSize']; - if ($maxFileSize > 0) { - return (float)min($maxFileSize * 1024 * 1024, $this->maxUploadSize->get()); - } - - return (float)$this->maxUploadSize->get(); + return (float)$validatorConfiguration['FileSizeValidator']['maxFileSize'] * 1024 * 1024; } /**