Throw exception if allowSvgImage is called w/o imageOnly flag is set
authorJoshua Rüsweg <josh@bastelstu.be>
Sun, 3 Feb 2019 18:43:33 +0000 (19:43 +0100)
committerJoshua Rüsweg <josh@bastelstu.be>
Sun, 3 Feb 2019 18:43:33 +0000 (19:43 +0100)
See #2825

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

index 3c0dff9dae1bab7ea02bbc0f98b23a4123d1f83a..4f30df8b93765f4ac0c5a52d5c96a905a26f8230 100644 (file)
@@ -242,8 +242,14 @@ class UploadFormField extends AbstractFormField {
         *
         * @param       boolean         $allowSvgImages
         * @return      static                          this field
+        * 
+        * @throws      \BadMethodCallException         if the imageOnly flag isn't set to true
         */
        public function allowSvgImage($allowSvgImages = true) {
+               if (!$this->isImageOnly()) {
+                       throw new \BadMethodCallException('Allowing SVG images is only relevant, if the `imageOnly` flag is set to `true`.');
+               }
+               
                $this->allowSvgImage = $allowSvgImages;
                
                return $this;