Simplify getValue method
authorJoshua Rüsweg <josh@bastelstu.be>
Sat, 19 Jan 2019 17:14:40 +0000 (18:14 +0100)
committerJoshua Rüsweg <josh@bastelstu.be>
Sat, 19 Jan 2019 17:14:40 +0000 (18:14 +0100)
See #2826

wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php

index 9046e971abaa277aad6b763f224f667e45ff110e..e4e2c4fa6301cb335af02fcd4cf304138b9aaab9 100644 (file)
@@ -64,22 +64,10 @@ class UploadFormField extends AbstractFormField {
        
        /**
         * @inheritDoc
-        * @return      UploadFile[][]
+        * @return      UploadFile[]
         */
        public function getValue() {
-               $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;
+               return UploadHandler::getInstance()->getFilesForFieldId($this->getId());
        }
        
        /**
@@ -103,14 +91,14 @@ class UploadFormField extends AbstractFormField {
                        }
                }
                
-               if ($this->getMinimum() !== null && count($this->getValue()['files']) < $this->getMinimum()) {
+               if ($this->getMinimum() !== null && count($this->getValue()) < $this->getMinimum()) {
                        $this->addValidationError(new FormFieldValidationError(
                                'minimum',
                                'wcf.form.field.upload.error.minimum',
                                ['minimum' => $this->getMinimum()]
                        ));
                }
-               else if ($this->getMaximum() !== null && count($this->getValue()['files']) > $this->getMaximum()) {
+               else if ($this->getMaximum() !== null && count($this->getValue()) > $this->getMaximum()) {
                        $this->addValidationError(new FormFieldValidationError(
                                'maximum',
                                'wcf.form.field.upload.error.maximum',