From: Cyperghost Date: Wed, 31 Jul 2024 05:41:48 +0000 (+0200) Subject: Add additional checks as to whether the `$bigPreview` is active or can be activated X-Git-Tag: 6.1.0_Alpha_1~31 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ba45d5966c77678a2f130c7ad8598238f914f978;p=GitHub%2FWoltLab%2FWCF.git Add additional checks as to whether the `$bigPreview` is active or can be activated --- diff --git a/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php index a41b418e81..3038e92020 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/FileProcessorFormField.class.php @@ -96,6 +96,12 @@ final class FileProcessorFormField extends AbstractFormField */ public function singleFileUpload(bool $singleFileUpload = true): self { + if (!$singleFileUpload && $this->bigPreview) { + throw new \InvalidArgumentException( + "Single file upload can't be disabled if the big preview is enabled for the field '{$this->getId()}'." + ); + } + $this->singleFileUpload = $singleFileUpload; return $this; @@ -229,7 +235,7 @@ final class FileProcessorFormField extends AbstractFormField public function bigPreview(bool $bigPreview = true): self { if ( - $this->bigPreview + $bigPreview && \array_diff( $this->getFileProcessor()->getAllowedFileExtensions($this->context), ImageUtil::IMAGE_EXTENSIONS @@ -239,6 +245,13 @@ final class FileProcessorFormField extends AbstractFormField "The big preview is only supported for images for the field '{$this->getId()}'." ); } + + if ($bigPreview && !$this->singleFileUpload) { + throw new \InvalidArgumentException( + "The big preview is only supported for single file uploads for the field '{$this->getId()}'." + ); + } + $this->bigPreview = $bigPreview; return $this;