Fix typo in method names
authorJoshua Rüsweg <josh@bastelstu.be>
Sun, 20 Jan 2019 17:16:43 +0000 (18:16 +0100)
committerJoshua Rüsweg <josh@bastelstu.be>
Sun, 20 Jan 2019 17:24:49 +0000 (18:24 +0100)
See #2825

wcfsetup/install/files/lib/action/AJAXFileUploadAction.class.php
wcfsetup/install/files/lib/system/file/upload/UploadHandler.class.php
wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php

index 01fe196857abfc2108b5b0d2e7a7ee5a22424682..13e472ec527ffeb72917038386616bcdfa00f444 100644 (file)
@@ -66,7 +66,7 @@ class AJAXFileUploadAction extends AbstractSecureAction {
                        throw new UserInputException('files', 'failed');
                }
                
-               if (UploadHandler::getInstance()->getFieldForInternalId($this->internalId)->getMaxFiles() !== null && UploadHandler::getInstance()->getFieldForInternalId($this->internalId)->getMaxFiles() < UploadHandler::getInstance()->getFilesCountForInternalId($this->internalId) + count($_FILES['__files']['tmp_name'])) {
+               if (UploadHandler::getInstance()->getFieldByInternalId($this->internalId)->getMaxFiles() !== null && UploadHandler::getInstance()->getFieldByInternalId($this->internalId)->getMaxFiles() < UploadHandler::getInstance()->getFilesCountByInternalId($this->internalId) + count($_FILES['__files']['tmp_name'])) {
                        throw new UserInputException('files', 'reachedRemainingLimit');
                }
        }
@@ -84,7 +84,7 @@ class AJAXFileUploadAction extends AbstractSecureAction {
                
                $i = 0;
                
-               $field = UploadHandler::getInstance()->getFieldForInternalId($this->internalId);
+               $field = UploadHandler::getInstance()->getFieldByInternalId($this->internalId);
                
                foreach ($_FILES['__files']['tmp_name'] as $id => $tmpName) {
                        if ($field->isImageOnly()) {
@@ -109,7 +109,7 @@ class AJAXFileUploadAction extends AbstractSecureAction {
                        
                        $uploadFile = new UploadFile($tmpFile, $_FILES['__files']['name'][$id]);
                        
-                       UploadHandler::getInstance()->addFileForInternalId($this->internalId, $uploadFile);
+                       UploadHandler::getInstance()->addFileByInternalId($this->internalId, $uploadFile);
                        
                        $this->uploadedFiles[$i++] = $uploadFile;
                }
index d9a7dc47365474e335f686b8e5c8f395aa3d9a6e..53bacb637aaaa7d9c788797f2467adfb8285866f 100644 (file)
@@ -63,12 +63,12 @@ class UploadHandler extends SingletonFactory {
         * 
         * @throws      \InvalidArgumentException       if the given fieldId is unknown
         */
-       public function getFilesForFieldId($fieldId) {
+       public function getFilesByFieldId($fieldId) {
                if (!isset($this->fields[$fieldId])) {
                        throw new \InvalidArgumentException('UploadField with the id "'. $fieldId .'" is unknown.');
                }
                
-               return $this->getFilesForInternalId($this->fields[$fieldId]->getInternalId());
+               return $this->getFilesByInternalId($this->fields[$fieldId]->getInternalId());
        }
        
        /**
@@ -80,12 +80,12 @@ class UploadHandler extends SingletonFactory {
         * 
         * @throws      \InvalidArgumentException       if the given fieldId is unknown
         */
-       public function getRemovedFiledForFieldId($fieldId, $processFiles = true) {
+       public function getRemovedFiledByFieldId($fieldId, $processFiles = true) {
                if (!isset($this->fields[$fieldId])) {
                        throw new \InvalidArgumentException('UploadField with the id "'. $fieldId .'" is unknown.');
                }
                
-               return $this->getRemovedFiledForInternalId($this->fields[$fieldId]->getInternalId(), $processFiles);
+               return $this->getRemovedFiledByInternalId($this->fields[$fieldId]->getInternalId(), $processFiles);
        }
        
        /**
@@ -95,7 +95,7 @@ class UploadHandler extends SingletonFactory {
         * @param       boolean         $processFiles
         * @return      UploadFile[]
         */
-       public function getRemovedFiledForInternalId($internalId, $processFiles = true) {
+       public function getRemovedFiledByInternalId($internalId, $processFiles = true) {
                if (isset($this->getStorage()[$internalId])) {
                        $files = $this->getStorage()[$internalId]['removedFiles'];
                        $removedFiles = [];
@@ -107,7 +107,7 @@ class UploadHandler extends SingletonFactory {
                                }
                        }
                        
-                       if ($processFiles) $this->processRemovedFiles($this->getFieldForInternalId($internalId));
+                       if ($processFiles) $this->processRemovedFiles($this->getFieldByInternalId($internalId));
                        
                        return $removedFiles;
                }
@@ -128,7 +128,7 @@ class UploadHandler extends SingletonFactory {
                        throw new \InvalidArgumentException('InternalId "'. $internalId .'" is unknown.');
                }
                
-               $file = $this->getFileForUniqueFileId($internalId, $uniqueFileId);
+               $file = $this->getFileByUniqueFileId($internalId, $uniqueFileId);
                
                if ($file === null) {
                        return; 
@@ -170,7 +170,7 @@ class UploadHandler extends SingletonFactory {
                return WCF::getTPL()->fetch('uploadFieldComponent', 'wcf', [
                        'uploadField' => $this->fields[$fieldId], 
                        'uploadFieldId' => $fieldId,
-                       'uploadFieldFiles' => $this->getFilesForFieldId($fieldId)
+                       'uploadFieldFiles' => $this->getFilesByFieldId($fieldId)
                ]);
        }
        
@@ -192,23 +192,24 @@ class UploadHandler extends SingletonFactory {
         * @return      boolean
         */
        public function isValidUniqueFileId($internalId, $uniqueFileId) {
-               return $this->getFileForUniqueFileId($internalId, $uniqueFileId) !== null; 
+               return $this->getFileByUniqueFileId($internalId, $uniqueFileId) !== null; 
        }
        
        /**
-        *
+        * Return all files by file id. 
+        * 
         * @param       string          $internalId
         * @param       string          $uniqueFileId
         * @return      UploadFile|null
         * 
         * @throws      \InvalidArgumentException       if the given internalId is unknown
         */
-       public function getFileForUniqueFileId($internalId, $uniqueFileId) {
+       public function getFileByUniqueFileId($internalId, $uniqueFileId) {
                if (!$this->isValidInternalId($internalId)) {
                        throw new \InvalidArgumentException('InternalId "'. $internalId .'" is unknown.');
                }
                
-               foreach ($this->getFilesForInternalId($internalId) as $file) {
+               foreach ($this->getFilesByInternalId($internalId) as $file) {
                        if (hash_equals($file->getUniqueFileId(), $uniqueFileId)) {
                                return $file;
                        }
@@ -223,8 +224,8 @@ class UploadHandler extends SingletonFactory {
         * @param       string          $internalId
         * @param       UploadFile      $file
         */
-       public function addFileForInternalId($internalId, UploadFile $file) {
-               $this->registerFilesForInternalId($internalId, array_merge($this->getFilesForInternalId($internalId), [$file]));
+       public function addFileByInternalId($internalId, UploadFile $file) {
+               $this->registerFilesByInternalId($internalId, array_merge($this->getFilesByInternalId($internalId), [$file]));
        }
        
        /**
@@ -238,7 +239,7 @@ class UploadHandler extends SingletonFactory {
         * 
         * @throws      \InvalidArgumentException       if the given internalId is unknown
         */
-       public function registerFilesForInternalId($internalId, array $files) {
+       public function registerFilesByInternalId($internalId, array $files) {
                if (!$this->isValidInternalId($internalId)) {
                        throw new \InvalidArgumentException('InternalId "'. $internalId .'" is unknown.');
                }
@@ -261,8 +262,8 @@ class UploadHandler extends SingletonFactory {
         * @param       string          $fieldId
         * @param       UploadFile      $file
         */
-       public function addFileForField($fieldId, UploadFile $file) {
-               $this->registerFilesForField($fieldId, array_merge($this->getFilesForFieldId($fieldId), [$file]));
+       public function addFileByField($fieldId, UploadFile $file) {
+               $this->registerFilesByField($fieldId, array_merge($this->getFilesByFieldId($fieldId), [$file]));
        }
        
        /**
@@ -276,12 +277,12 @@ class UploadHandler extends SingletonFactory {
         * 
         * @throws      \InvalidArgumentException       if the given fieldId is unknown
         */
-       public function registerFilesForField($fieldId, array $files) {
+       public function registerFilesByField($fieldId, array $files) {
                if (!isset($this->fields[$fieldId])) {
                        throw new \InvalidArgumentException('UploadField with the id "'. $fieldId .'" is unknown.');
                }
                
-               $this->registerFilesForInternalId($this->fields[$fieldId]->getInternalId(), $files);
+               $this->registerFilesByInternalId($this->fields[$fieldId]->getInternalId(), $files);
        }
        
        /**
@@ -292,7 +293,7 @@ class UploadHandler extends SingletonFactory {
         * 
         * @throws      \InvalidArgumentException       if the given internalId is unknown
         */
-       public function getFieldForInternalId($internalId) {
+       public function getFieldByInternalId($internalId) {
                if (!$this->isValidInternalId($internalId)) {
                        throw new \InvalidArgumentException('InternalId "'. $internalId .'" is unknown.');
                }
@@ -306,8 +307,8 @@ class UploadHandler extends SingletonFactory {
         * @param       string          $internalId
         * @return      int
         */
-       public function getFilesCountForInternalId($internalId) {
-               return count($this->getFilesForInternalId($internalId));
+       public function getFilesCountByInternalId($internalId) {
+               return count($this->getFilesByInternalId($internalId));
        }
        
        /**
@@ -326,7 +327,7 @@ class UploadHandler extends SingletonFactory {
         * @param       string          $internalId
         * @return      UploadFile[]
         */
-       private function getFilesForInternalId($internalId) {
+       private function getFilesByInternalId($internalId) {
                if (isset($this->getStorage()[$internalId])) {
                        $files = $this->getStorage()[$internalId]['files'];
                        
index e4e2c4fa6301cb335af02fcd4cf304138b9aaab9..d145ca3f89b384791847a1fab36289b9e9883272 100644 (file)
@@ -67,7 +67,7 @@ class UploadFormField extends AbstractFormField {
         * @return      UploadFile[]
         */
        public function getValue() {
-               return UploadHandler::getInstance()->getFilesForFieldId($this->getId());
+               return UploadHandler::getInstance()->getFilesByFieldId($this->getId());
        }
        
        /**
@@ -137,7 +137,7 @@ class UploadFormField extends AbstractFormField {
                
                $this->registerField();
                
-               UploadHandler::getInstance()->registerFilesForField($this->getId(), $value);
+               UploadHandler::getInstance()->registerFilesByField($this->getId(), $value);
        }
        
        /**