}
}
+ /**
+ * Unregisters an upload field by the given field id.
+ *
+ * @param string $fieldId
+ *
+ * @throws \InvalidArgumentException if the given fieldId is unknown
+ */
+ public function unregisterUploadField($fieldId) {
+ if (!isset($this->fields[$fieldId])) {
+ throw new \InvalidArgumentException('UploadField with the id "'. $fieldId .'" is unknown.');
+ }
+
+ $storage = $this->getStorage();
+ unset($storage[$this->fields[$fieldId]->getInternalId()]);
+
+ WCF::getSession()->register(self::UPLOAD_HANDLER_SESSION_VAR, $storage);
+
+ unset($this->fields[$fieldId]);
+ }
+
/**
* Returns the uploaded files for a specific fieldId.
*
}
}
+ /**
+ * Unregisters the current field in the upload handler.
+ */
+ private function unregisterField() {
+ if (UploadHandler::getInstance()->isRegisteredFieldId($this->getId())) {
+ UploadHandler::getInstance()->unregisterUploadField($this->getId());
+ }
+ }
+
/**
* Builds the UploadField class.
*
return false;
}
+ /**
+ * @inheritDoc
+ */
+ public function cleanup() {
+ $this->unregisterField();
+
+ return $this;
+ }
+
/**
* @inheritDoc
*