From: Joshua Rüsweg Date: Tue, 15 Jan 2019 21:32:18 +0000 (+0100) Subject: Return files, newFiles and removedFiles in getValue() X-Git-Tag: 5.2.0_Alpha_1~296^2~36 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b850d730687cf353ebb438c2abc35dfd07955598;p=GitHub%2FWoltLab%2FWCF.git Return files, newFiles and removedFiles in getValue() See #2825 --- diff --git a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php index 30911da0ff..690cdded14 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php @@ -65,10 +65,22 @@ class UploadFormField extends AbstractFormField { /** * @inheritDoc - * @return UploadFile[] + * @return UploadFile[][] */ public function getValue() { - return UploadHandler::getInstance()->getFilesForFieldId($this->getId()); + $returnValues = [ + 'files' => UploadHandler::getInstance()->getFilesForFieldId($this->getId()), + 'newFiles' => [], + 'removedFiles' => UploadHandler::getInstance()->getRemovedFiledForFieldId($this->getId(), false) + ]; + + foreach (UploadHandler::getInstance()->getFilesForFieldId($this->getId()) as $file) { + if (!$file->isProcessed()) { + $returnValues['newFiles'][] = $file; + } + } + + return $returnValues; } /** @@ -92,14 +104,14 @@ class UploadFormField extends AbstractFormField { } } - if ($this->getMinimum() !== null && count($this->getValue()) < $this->getMinimum()) { + if ($this->getMinimum() !== null && count($this->getValue()['files']) < $this->getMinimum()) { $this->addValidationError(new FormFieldValidationError( 'minimum', 'wcf.form.field.upload.error.minimum', ['minimum' => $this->getMinimum()] )); } - else if ($this->getMaximum() !== null && count($this->getValue()) > $this->getMaximum()) { + else if ($this->getMaximum() !== null && count($this->getValue()['files']) > $this->getMaximum()) { $this->addValidationError(new FormFieldValidationError( 'maximum', 'wcf.form.field.upload.error.maximum',