/** * Get Error messages for validator Errors * * @param string[] $errors Array of validation failure message codes @see \Zend_Validate::getErrors() * @param array $fileInfo File info * @param \Magento\Catalog\Model\Product\Option $option * @return string[] Array of error messages * @see \Magento\Catalog\Model\Product\Option\Type\File::_getValidatorErrors */ protected function getValidatorErrors($errors, $fileInfo, $option) { $result = []; foreach ($errors as $errorCode) { switch ($errorCode) { case \Zend_Validate_File_ExcludeExtension::FALSE_EXTENSION: $result[] = __("The file '%1' for '%2' has an invalid extension.", $fileInfo['title'], $option->getTitle()); break; case \Zend_Validate_File_Extension::FALSE_EXTENSION: $result[] = __("The file '%1' for '%2' has an invalid extension.", $fileInfo['title'], $option->getTitle()); break; case \Zend_Validate_File_ImageSize::WIDTH_TOO_BIG: case \Zend_Validate_File_ImageSize::HEIGHT_TOO_BIG: $result[] = __("The maximum allowed image size for '%1' is %2x%3 px.", $option->getTitle(), $option->getImageSizeX(), $option->getImageSizeY()); break; case \Zend_Validate_File_FilesSize::TOO_BIG: $result[] = __("The file '%1' you uploaded is larger than the %2 megabytes allowed by our server.", $fileInfo['title'], $this->fileSize->getMaxFileSizeInMb()); break; case \Zend_Validate_File_ImageSize::NOT_DETECTED: $result[] = __("The file '%1' is empty. Please choose another one", $fileInfo['title']); break; default: $result[] = __("The file '%1' is invalid. Please choose another one", $fileInfo['title']); } } return $result; }
/** * Get maximum upload size message * * @return string */ public function getMaxUploadSizeMessage() { $maxImageSize = $this->_fileSize->getMaxFileSizeInMb(); if ($maxImageSize) { $message = __('The total size of the uploadable files can\'t be more than %1M', $maxImageSize); } else { $message = __('System doesn\'t allow to get file upload settings'); } return $message; }
/** * Get maximum upload size message * * @return \Magento\Framework\Phrase */ public function getMaxUploadSizeMessage() { $maxImageSize = $this->_fileSize->getMaxFileSizeInMb(); if ($maxImageSize) { $message = __('Make sure your file isn\'t more than %1M.', $maxImageSize); } else { $message = __('We can\'t provide the upload settings right now.'); } return $message; }
/** * Get note string for theme's preview image * * @return \Magento\Framework\Phrase */ protected function _getPreviewImageNote() { $maxImageSize = $this->_fileSize->getMaxFileSizeInMb(); if ($maxImageSize) { return __('Max image size %1M', $maxImageSize); } else { return __('Something is wrong with the file upload settings.'); } }
/** * @backupStaticAttributes */ public function testGetMaxFileSize() { $this->assertGreaterThanOrEqual(0, $this->_fileSize->getMaxFileSize()); $this->assertGreaterThanOrEqual(0, $this->_fileSize->getMaxFileSizeInMb()); }