3 namespace wcf\system\upload
;
6 * Upload file validation strategy implementation for media files.
8 * @author Matthias Schmidt
9 * @copyright 2001-2019 WoltLab GmbH
10 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
11 * @package WoltLabSuite\Core\System\Upload
14 class MediaUploadFileValidationStrategy
implements IUploadFileValidationStrategy
17 * if `true`, only images are valid
20 protected $imagesOnly = false;
23 * Creates a new instance of MediaUploadFileValidationStrategy.
25 * @param bool $imagesOnly
27 public function __construct($imagesOnly)
29 $this->imagesOnly
= $imagesOnly;
35 public function validate(UploadFile
$uploadFile)
37 if ($uploadFile->getErrorCode()) {
38 $uploadFile->setValidationErrorType('uploadFailed');
43 if ($this->imagesOnly
&& $uploadFile->getImageData() === null) {
44 $uploadFile->setValidationErrorType('noImage');