From 50af9d2651804438bd486a14acffae086b120cfb Mon Sep 17 00:00:00 2001 From: joshuaruesweg Date: Tue, 13 Apr 2021 15:15:48 +0200 Subject: [PATCH] Make registerField() protected to allow using them in child classes --- .../builder/field/UploadFormField.class.php | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php index 6fb9018636..62c0e6f64a 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/UploadFormField.class.php @@ -119,6 +119,16 @@ class UploadFormField extends AbstractFormField } } + /** + * Returns true, if the current field is already registered. + * + * @since 5.4 + */ + protected function isRegistered(): bool + { + return $this->isRegistered; + } + /** * Builds the UploadField class. * @@ -148,7 +158,7 @@ class UploadFormField extends AbstractFormField throw new \BadMethodCallException("The field must be populated, before calling this method."); } - if (!$this->isRegistered) { + if (!$this->isRegistered()) { $this->registerField(); } @@ -168,7 +178,7 @@ class UploadFormField extends AbstractFormField throw new \BadMethodCallException("The field must be populated, before calling the method."); } - if (!$this->isRegistered) { + if (!$this->isRegistered()) { $this->registerField(); } @@ -293,7 +303,7 @@ class UploadFormField extends AbstractFormField throw new \BadMethodCallException("The field must be populated, before calling this method."); } - if (!$this->isRegistered) { + if (!$this->isRegistered()) { $this->registerField(); } @@ -310,7 +320,7 @@ class UploadFormField extends AbstractFormField throw new \BadMethodCallException("The field must be populated, before calling this method."); } - if (!$this->isRegistered) { + if (!$this->isRegistered()) { $this->registerField(); } @@ -390,7 +400,7 @@ class UploadFormField extends AbstractFormField } } - if ($this->isRegistered) { + if ($this->isRegistered()) { UploadHandler::getInstance()->registerFilesByField($this->getPrefixedId(), $value); } else { $this->values = $value; @@ -442,7 +452,7 @@ class UploadFormField extends AbstractFormField * @since 5.4 * @throws \BadMethodCallException if the field is already registered */ - private function registerField(): void + protected function registerField(): void { if ($this->isRegistered) { throw new \BadMethodCallException("The field is already registered."); @@ -471,7 +481,7 @@ class UploadFormField extends AbstractFormField */ public function maximum($maximum = null) { - if ($this->isRegistered) { + if ($this->isRegistered()) { throw new \LogicException( 'The upload field has already been registered. Therefore no modifications are allowed.' ); -- 2.20.1