From: Matthias Schmidt Date: Thu, 25 Jul 2019 16:29:27 +0000 (+0200) Subject: Rework form data processors to allow data processing in both directions X-Git-Tag: 5.2.0_Alpha_3~10 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=5d086ddf93286ef5e21e861e52dc794e4fe9d45e;p=GitHub%2FWoltLab%2FWCF.git Rework form data processors to allow data processing in both directions i.e. processing form data to be used by a DBOAction and processing object data to be used as form field values. Close #2988 --- diff --git a/wcfsetup/install/files/lib/acp/form/LanguageItemAddForm.class.php b/wcfsetup/install/files/lib/acp/form/LanguageItemAddForm.class.php index 0dd7bb8dcb..1c27e45483 100644 --- a/wcfsetup/install/files/lib/acp/form/LanguageItemAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LanguageItemAddForm.class.php @@ -5,8 +5,8 @@ use wcf\data\language\item\LanguageItemAction; use wcf\data\language\item\LanguageItemList; use wcf\form\AbstractFormBuilderForm; use wcf\system\form\builder\container\FormContainer; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; -use wcf\system\form\builder\field\data\processor\VoidFormFieldDataProcessor; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; +use wcf\system\form\builder\data\processor\VoidFormDataProcessor; use wcf\system\form\builder\field\dependency\ValueFormFieldDependency; use wcf\system\form\builder\field\MultilineTextFormField; use wcf\system\form\builder\field\RadioButtonFormField; @@ -166,10 +166,10 @@ class LanguageItemAddForm extends AbstractFormBuilderForm { // `languageCategoryIDMode` is an internal field not meant to be // treated as real data - $this->form->getDataHandler()->add(new VoidFormFieldDataProcessor('languageCategoryIDMode')); + $this->form->getDataHandler()->addProcessor(new VoidFormDataProcessor('languageCategoryIDMode')); - $this->form->getDataHandler()->add( - new CustomFormFieldDataProcessor('languageItemOriginIsSystem', function(IFormDocument $document, array $parameters) { + $this->form->getDataHandler()->addProcessor( + new CustomFormDataProcessor('languageItemOriginIsSystem', function(IFormDocument $document, array $parameters) { $parameters['data']['languageItemOriginIsSystem'] = 0; $parameters['data']['isCustomLanguageItem'] = 1; diff --git a/wcfsetup/install/files/lib/data/DatabaseObject.class.php b/wcfsetup/install/files/lib/data/DatabaseObject.class.php index 99e9056411..021e279770 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObject.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObject.class.php @@ -116,8 +116,7 @@ abstract class DatabaseObject implements IIDObject, IStorableObject { } /** - * @deprecated This method was introduced for a function in AJAXProxy that is deprecated. - * @see \wcf\data\IStorableObject::getData() + * @inheritDoc */ public function getData() { return $this->data; diff --git a/wcfsetup/install/files/lib/data/IStorableObject.class.php b/wcfsetup/install/files/lib/data/IStorableObject.class.php index 5f1767215f..875a6518f8 100644 --- a/wcfsetup/install/files/lib/data/IStorableObject.class.php +++ b/wcfsetup/install/files/lib/data/IStorableObject.class.php @@ -31,7 +31,6 @@ interface IStorableObject { /** * Returns the value of all object data variables. * - * @deprecated This method was introduced for a function in AJAXProxy that is deprecated. * @return mixed[] */ public function getData(); diff --git a/wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php b/wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php index 48555ada6a..509b339393 100644 --- a/wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php @@ -6,7 +6,7 @@ use wcf\system\form\builder\button\IFormButton; use wcf\system\form\builder\container\IFormContainer; use wcf\system\form\builder\data\FormDataHandler; use wcf\system\form\builder\data\IFormDataHandler; -use wcf\system\form\builder\field\data\processor\DefaultFormFieldDataProcessor; +use wcf\system\form\builder\data\processor\DefaultFormDataProcessor; use wcf\system\form\builder\field\IFileFormField; use wcf\system\form\builder\field\IFormField; use wcf\system\WCF; @@ -338,7 +338,7 @@ class FormDocument implements IFormDocument { throw new \BadMethodCallException("Getting data is only possible after calling 'readValues()'."); } - return $this->getDataHandler()->getData($this); + return $this->getDataHandler()->getFormData($this); } /** @@ -347,7 +347,7 @@ class FormDocument implements IFormDocument { public function getDataHandler() { if ($this->dataHandler === null) { $this->dataHandler = new FormDataHandler(); - $this->dataHandler->add(new DefaultFormFieldDataProcessor()); + $this->dataHandler->addProcessor(new DefaultFormDataProcessor()); } return $this->dataHandler; @@ -535,13 +535,15 @@ class FormDocument implements IFormDocument { $this->formMode(self::FORM_MODE_UPDATE); } + $data = $this->getDataHandler()->getObjectData($this, $object); + /** @var IFormNode $node */ foreach ($this->getIterator() as $node) { if ($node->isAvailable()) { if ($node instanceof IFormField) { if ($node->getObjectProperty() !== $node->getId()) { try { - $node->loadValueFromObject($object); + $node->loadValue($data, $object); } catch (\InvalidArgumentException $e) { // if an object property is explicitly set, @@ -550,11 +552,11 @@ class FormDocument implements IFormDocument { } } else { - $node->loadValueFromObject($object); + $node->loadValue($data, $object); } } else if ($node instanceof IFormContainer) { - $node->loadValuesFromObject($object); + $node->loadValues($data, $object); } } } diff --git a/wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php index 35fd43f87a..c2653d5e74 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/FormContainer.class.php @@ -50,7 +50,7 @@ class FormContainer implements IFormContainer { /** * @inheritDoc */ - public function loadValuesFromObject(IStorableObject $object) { + public function loadValues(array $data, IStorableObject $object) { // does nothing return $this; diff --git a/wcfsetup/install/files/lib/system/form/builder/container/IFormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/IFormContainer.class.php index 5e80f09ddf..fb3cb77a62 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/IFormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/IFormContainer.class.php @@ -16,14 +16,15 @@ use wcf\system\form\builder\IFormParentNode; */ interface IFormContainer extends IFormChildNode, IFormElement, IFormParentNode { /** - * This method is called by `IFormDocument::loadValuesFromObject()` to inform the container - * that object data is loaded. + * This method is called by `IFormDocument::loadValue()` to inform the container that object + * data is being loaded. * - * This method is *not* intended to generally call `IFormField::loadValueFromObject()` on - * its form field children as these methods are already called by `IFormDocument::loadValuesFromObject()`. - * - * @param IStorableObject $object object used to load field values + * This method is *not* intended to generally call `IFormField::loadValue()` on its form field + * children as these methods are already called by `IFormDocument::loadValuesFromObject()`. + * + * @param array $data data from which the values are extracted + * @param IStorableObject $object object the data belongs to * @return static this container */ - public function loadValuesFromObject(IStorableObject $object); + public function loadValues(array $data, IStorableObject $object); } diff --git a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php index 403fb94083..179df2d2d1 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php @@ -342,8 +342,8 @@ class WysiwygFormContainer extends FormContainer implements IMaximumLengthFormFi /** * @inheritDoc */ - public function loadValuesFromObject(IStorableObject $object) { - $this->objectId = $object->getObjectID(); + public function loadValues(array $data, IStorableObject $object) { + $this->objectId = $object->{$object::getDatabaseTableIndexName()}; if ($this->attachmentData !== null) { // updated attachment handler with object id @@ -357,7 +357,7 @@ class WysiwygFormContainer extends FormContainer implements IMaximumLengthFormFi ); } - return parent::loadValuesFromObject($object); + return parent::loadValues($data, $object); } /** diff --git a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygPollFormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygPollFormContainer.class.php index 4e56278f56..250ebd6027 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygPollFormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygPollFormContainer.class.php @@ -4,8 +4,8 @@ use wcf\data\IPollContainer; use wcf\data\IStorableObject; use wcf\data\poll\Poll; use wcf\system\form\builder\container\FormContainer; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\BooleanFormField; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; use wcf\system\form\builder\field\DateFormField; use wcf\system\form\builder\field\IntegerFormField; use wcf\system\form\builder\field\poll\PollOptionsFormField; @@ -226,9 +226,9 @@ class WysiwygPollFormContainer extends FormContainer implements IObjectTypeFormN /** * @inheritDoc */ - public function loadValuesFromObject(IStorableObject $object) { - if ($object instanceof IPollContainer && $object->getPollID() !== null) { - $this->poll = new Poll($object->getPollID()); + public function loadValues(array $data, IStorableObject $object) { + if ($data instanceof IPollContainer && $data->getPollID() !== null) { + $this->poll = new Poll($data->getPollID()); if (!$this->poll->pollID) { $this->poll = null; } @@ -247,7 +247,7 @@ class WysiwygPollFormContainer extends FormContainer implements IObjectTypeFormN $this->getSortByVotesField()->value($this->poll->sortByVotes); } - return parent::loadValuesFromObject($object); + return parent::loadValues($data, $object); } /** @@ -259,7 +259,7 @@ class WysiwygPollFormContainer extends FormContainer implements IObjectTypeFormN $id = $this->wysiwygId . 'Poll'; // add data handler to group poll data into a sub-array of parameters - $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor($id, function(IFormDocument $document, array $parameters) use($id) { + $this->getDocument()->getDataHandler()->addProcessor(new CustomFormDataProcessor($id, function(IFormDocument $document, array $parameters) use($id) { if (!$this->isAvailable()) { return $parameters; } diff --git a/wcfsetup/install/files/lib/system/form/builder/data/FormDataHandler.class.php b/wcfsetup/install/files/lib/system/form/builder/data/FormDataHandler.class.php index 1cddc67f20..5fd0a23d81 100644 --- a/wcfsetup/install/files/lib/system/form/builder/data/FormDataHandler.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/data/FormDataHandler.class.php @@ -1,6 +1,8 @@ processors[] = $processor; return $this; @@ -32,12 +34,43 @@ class FormDataHandler implements IFormDataHandler { /** * @inheritDoc */ - public function getData(IFormDocument $document) { + public function getFormData(IFormDocument $document) { $parameters = []; foreach ($this->processors as $processor) { - $parameters = $processor($document, $parameters); + $parameters = $processor->processFormData($document, $parameters); + + if (!is_array($parameters)) { + if ($processor instanceof CustomFormDataProcessor) { + throw new \UnexpectedValueException("Custom data processor '{$processor->getId()}' does not return an array when processing form data."); + } + else { + throw new \UnexpectedValueException("Data processor '" . get_class($processor) . "' does not return an array when processing form data."); + } + } } return $parameters; } + + /** + * @inheritDoc + */ + public function getObjectData(IFormDocument $document, IStorableObject $object) { + $data = $object->getData(); + $objectId = $object->{$object::getDatabaseTableIndexName()}; + foreach ($this->processors as $processor) { + $data = $processor->processObjectData($document, $data, $objectId); + + if (!is_array($data)) { + if ($processor instanceof CustomFormDataProcessor) { + throw new \UnexpectedValueException("Custom data processor '{$processor->getId()}' does not return an array when processing object data."); + } + else { + throw new \UnexpectedValueException("Data processor '" . get_class($processor) . "' does not return an array when processing object data."); + } + } + } + + return $data; + } } diff --git a/wcfsetup/install/files/lib/system/form/builder/data/IFormDataHandler.class.php b/wcfsetup/install/files/lib/system/form/builder/data/IFormDataHandler.class.php index 752a35a598..9d72f73e81 100644 --- a/wcfsetup/install/files/lib/system/form/builder/data/IFormDataHandler.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/data/IFormDataHandler.class.php @@ -1,6 +1,7 @@ + * @package WoltLabSuite\Core\System\Form\Builder\Data\Processor + * @since 5.2 + */ +abstract class AbstractFormDataProcessor implements IFormDataProcessor { + /** + * @inheritDoc + */ + public function processFormData(IFormDocument $document, array $parameters) { + return $parameters; + } + + /** + * @inheritDoc + */ + public function processObjectData(IFormDocument $document, array $data, $objectId = null) { + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/form/builder/data/processor/CustomFormDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/data/processor/CustomFormDataProcessor.class.php new file mode 100644 index 0000000000..04599e92ee --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/data/processor/CustomFormDataProcessor.class.php @@ -0,0 +1,146 @@ + + * @package WoltLabSuite\Core\System\Form\Builder\Data\Processor + * @since 5.2 + */ +class CustomFormDataProcessor extends AbstractFormDataProcessor { + /** + * callable processing the form data + * @var callable + */ + protected $formDataProcessor; + + /** + * processor id primarily used for error messages + * @var string + */ + protected $id; + + /** + * callable processing the object data + * @var callable + */ + protected $objectDataProcessor; + + /** + * Initializes a new CustomFormFieldDataProcessor object. + * + * @param string $id processor id primarily used for error messages, does not have to be unique + * @param callable $formDataProcessor form data processor callable + * @param callable $objectDataProcessor object data processor callable + * + * @throws \InvalidArgumentException if either id or processor callable are invalid + */ + public function __construct($id, callable $formDataProcessor = null, callable $objectDataProcessor = null) { + if (preg_match('~^[a-z][A-z0-9-]*$~', $id) !== 1) { + throw new \InvalidArgumentException("Invalid id '{$id}' given."); + } + + $this->id = $id; + + if ($formDataProcessor === null && $objectDataProcessor === null) { + throw new \InvalidArgumentException("No processors given."); + } + + // validate form data processor function + if ($formDataProcessor !== null) { + $parameters = (new \ReflectionFunction($formDataProcessor))->getParameters(); + if (count($parameters) !== 2) { + throw new \InvalidArgumentException( + "The form data processor function must expect two parameters, instead " . count($parameters) . + " parameter" . (count($parameters) !== 1 ? 's' : '') . " are expected." + ); + } + + /** @var \ReflectionClass $parameterClass */ + $parameterClass = $parameters[0]->getClass(); + if ($parameterClass === null || ($parameterClass->getName() !== IFormDocument::class && !is_subclass_of($parameterClass->getName(), IFormDocument::class))) { + throw new \InvalidArgumentException( + "The form data processor function's first parameter must be an instance of '" . IFormDocument::class . "', instead " . + ($parameterClass === null ? 'any' : "'" . $parameterClass->getName() . "'") . " parameter is expected." + ); + } + if (!$parameters[1]->isArray()) { + throw new \InvalidArgumentException("The form data processor function's second parameter must be an array."); + } + + $this->formDataProcessor = $formDataProcessor; + } + + // validate object data processor function + if ($objectDataProcessor !== null) { + $parameters = (new \ReflectionFunction($objectDataProcessor))->getParameters(); + if (count($parameters) !== 3) { + throw new \InvalidArgumentException( + "The object data processor function must expect three parameters, instead " . count($parameters) . + " parameter" . (count($parameters) !== 1 ? 's' : '') . " are expected." + ); + } + + /** @var \ReflectionClass $parameterClass */ + $parameterClass = $parameters[0]->getClass(); + if ($parameterClass === null || ($parameterClass->getName() !== IFormDocument::class && !is_subclass_of($parameterClass->getName(), IFormDocument::class))) { + throw new \InvalidArgumentException( + "The object data processor function's first parameter must be an instance of '" . IFormDocument::class . "', instead " . + ($parameterClass === null ? 'any' : "'" . $parameterClass->getName() . "'") . " parameter is expected." + ); + } + if (!$parameters[1]->isArray()) { + throw new \InvalidArgumentException("The object data processor function's second parameter must be an array."); + } + + $this->objectDataProcessor = $objectDataProcessor; + } + } + + /** + * Returns the id of the data processor (which is primarily used for error messages). + * + * @return string + */ + public function getId() { + return $this->id; + } + + /** + * @inheritDoc + */ + public function processFormData(IFormDocument $document, array $parameters) { + if ($this->formDataProcessor === null) { + return parent::processFormData($document, $parameters); + } + + $parameters = call_user_func($this->formDataProcessor, $document, $parameters); + + if (!is_array($parameters)) { + throw new \UnexpectedValueException("Field data processor '{$this->id}' does not return an array."); + } + + return $parameters; + } + + /** + * @inheritDoc + */ + public function processObjectData(IFormDocument $document, array $data, $objectId = null) { + if ($this->objectDataProcessor === null) { + return parent::processObjectData($document, $data, $objectId); + } + + $data = call_user_func($this->objectDataProcessor, $document, $data, $objectId); + + if (!is_array($data)) { + throw new \UnexpectedValueException("Field data processor '{$this->id}' does not return an array."); + } + + return $data; + } +} diff --git a/wcfsetup/install/files/lib/system/form/builder/data/processor/DefaultFormDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/data/processor/DefaultFormDataProcessor.class.php new file mode 100644 index 0000000000..7cccbe826e --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/data/processor/DefaultFormDataProcessor.class.php @@ -0,0 +1,49 @@ + + * @package WoltLabSuite\Core\System\Form\Builder\Data\Processor + * @since 5.2 + */ +class DefaultFormDataProcessor extends AbstractFormDataProcessor { + /** + * @inheritDoc + */ + public function processFormData(IFormDocument $document, array $parameters) { + $parameters['data'] = []; + + $this->getData($document, $parameters['data']); + + return $parameters; + } + + /** + * Fetches all data from the given node and stores it in the given array. + * + * @param IFormNode $node node whose data will be fetched + * @param array $data data storage + */ + protected function getData(IFormNode $node, array &$data) { + if ($node->isAvailable() && $node->checkDependencies()) { + if ($node instanceof IFormParentNode) { + foreach ($node as $childNode) { + $this->getData($childNode, $data); + } + } + else if ($node instanceof IFormField && $node->isAvailable() && $node->hasSaveValue()) { + $data[$node->getObjectProperty()] = $node->getSaveValue(); + } + } + } +} diff --git a/wcfsetup/install/files/lib/system/form/builder/data/processor/IFormDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/data/processor/IFormDataProcessor.class.php new file mode 100644 index 0000000000..21964b2e38 --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/data/processor/IFormDataProcessor.class.php @@ -0,0 +1,37 @@ + + * @package WoltLabSuite\Core\System\Form\Builder\Data\Processor + * @since 5.2 + */ +interface IFormDataProcessor { + /** + * Processes the given parameters array and returns the processed version of it that will be + * passed to the constructor of a database object action. + * + * @param IFormDocument $document documents whose field data is processed + * @param array $parameters parameters before processing + * @return array parameters after processing + */ + public function processFormData(IFormDocument $document, array $parameters); + + /** + * Processes the given object data and returns the processed version of it that will be used + * to set the form field values. + * + * @param IFormDocument $document documents whose field values will be set using the processed data + * @param array $data data before processing + * @param null|integer $objectId id of the object the data belongs to + * @return array data after processing + */ + public function processObjectData(IFormDocument $document, array $data, $objectId = null); +} diff --git a/wcfsetup/install/files/lib/system/form/builder/data/processor/VoidFormDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/data/processor/VoidFormDataProcessor.class.php new file mode 100644 index 0000000000..1a3b0ad41d --- /dev/null +++ b/wcfsetup/install/files/lib/system/form/builder/data/processor/VoidFormDataProcessor.class.php @@ -0,0 +1,53 @@ + + * @package WoltLabSuite\Core\System\Form\Builder\Data\Processor + * @since 5.2 + */ +class VoidFormDataProcessor extends AbstractFormDataProcessor { + /** + * is `true` if the property is stored in the `data` array + * @var bool + */ + protected $isDataProperty; + + /** + * name of the voided property + * @var string + */ + protected $property; + + /** + * Initializes a new CustomFormFieldDataProcessor object. + * + * @param string $property name of the voided property + * @param bool $isDataProperty is `true` if the property is stored in the `data` array + */ + public function __construct($property, $isDataProperty = true) { + $this->property = $property; + $this->isDataProperty = $isDataProperty; + } + + /** + * @inheritDoc + */ + public function processFormData(IFormDocument $document, array $parameters) { + if ($this->isDataProperty) { + if (isset($parameters['data'][$this->property])) { + unset($parameters['data'][$this->property]); + } + } + else if (isset($parameters[$this->property])) { + unset($parameters[$this->property]); + } + + return $parameters; + } +} diff --git a/wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php index a1b10e21eb..1f016034b5 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/AbstractFormField.class.php @@ -177,9 +177,9 @@ abstract class AbstractFormField implements IFormField { /** * @inheritDoc */ - public function loadValueFromObject(IStorableObject $object) { - if (isset($object->{$this->getObjectProperty()})) { - $this->value($object->{$this->getObjectProperty()}); + public function loadValue(array $data, IStorableObject $object) { + if (isset($data[$this->getObjectProperty()])) { + $this->value($data[$this->getObjectProperty()]); } return $this; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/IFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/IFormField.class.php index fd66171628..0521237759 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/IFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/IFormField.class.php @@ -108,12 +108,16 @@ interface IFormField extends IFormChildNode, IFormElement { public function isRequired(); /** - * Loads the field value from the given object and returns this field. + * Loads the field value from the given data and returns this field. * - * @param IStorableObject $object object used to load field value + * It is important to extract the value from the `$data` array instead of getting it directly + * from the object as the entries of `$data` have been processed by the data processors. + * + * @param array $data data from which the value is extracted + * @param IStorableObject $object object the data belongs to * @return static this field */ - public function loadValueFromObject(IStorableObject $object); + public function loadValue(array $data, IStorableObject $object); /** * Sets the name of the object property this field represents. If an empty diff --git a/wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php index a98eede6c7..e04e6e784b 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php @@ -1,6 +1,6 @@ getSaveValueType() === self::SAVE_VALUE_TYPE_ARRAY) { - $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('itemList', function(IFormDocument $document, array $parameters) { + $this->getDocument()->getDataHandler()->addProcessor(new CustomFormDataProcessor('itemList', function(IFormDocument $document, array $parameters) { if ($this->checkDependencies() && is_array($this->getValue())) { $parameters[$this->getObjectProperty()] = $this->getValue(); } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php index 6d26b67d44..601920bb96 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php @@ -1,8 +1,8 @@ {$this->getId()})) { - $value = $object->{$this->getId()}; + public function loadValueFromObject(array $data, IStorableObject $object) { + if (isset($data[$this->getObjectProperty()])) { + $value = $data[$this->getObjectProperty()]; if ($this->isI18n()) { // do not use `I18nHandler::setOptions()` because then `I18nHandler` only @@ -286,7 +286,7 @@ trait TI18nFormField { /** @var IFormDocument $document */ $document = $this->getDocument(); - $document->getDataHandler()->add(new CustomFormFieldDataProcessor('i18n', function(IFormDocument $document, array $parameters) { + $document->getDataHandler()->addProcessor(new CustomFormDataProcessor('i18n', function(IFormDocument $document, array $parameters) { if ($this->checkDependencies() && $this->hasI18nValues()) { $parameters[$this->getObjectProperty() . '_i18n'] = $this->getValue(); } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/TMultipleFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/TMultipleFormField.class.php index a18365fc7c..a3f334f3dd 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/TMultipleFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/TMultipleFormField.class.php @@ -1,6 +1,6 @@ allowsMultiple()) { - $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('multiple', function(IFormDocument $document, array $parameters) { + $this->getDocument()->getDataHandler()->add(new CustomFormDataProcessor('multiple', function(IFormDocument $document, array $parameters) { if ($this->checkDependencies() && !empty($this->getValue())) { $parameters[$this->getObjectProperty()] = $this->getValue(); } 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 41f8012f23..e1aa5d987a 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 @@ -4,7 +4,7 @@ use wcf\data\IStorableObject; use wcf\system\file\upload\UploadField; use wcf\system\file\upload\UploadFile; use wcf\system\file\upload\UploadHandler; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\validation\FormFieldValidationError; use wcf\system\form\builder\IFormDocument; @@ -172,7 +172,7 @@ class UploadFormField extends AbstractFormField { * * @throws \InvalidArgumentException if the getter for the value provides invalid values */ - public function loadValueFromObject(IStorableObject $object) { + public function loadValue(array $data, IStorableObject $object) { // first check, whether an getter for the field exists if (method_exists($object, 'get'. ucfirst($this->getObjectProperty()) . 'UploadFileLocations')) { $value = call_user_func([$object, 'get'. ucfirst($this->getObjectProperty()) . 'UploadFileLocations']); @@ -183,7 +183,7 @@ class UploadFormField extends AbstractFormField { $method = "method '" . get_class($object) . "::get" . ucfirst($this->getObjectProperty()) . "()'"; } else { - $value = $object->{$this->getObjectProperty()}; + $value = $data[$this->getObjectProperty()]; $method = "variable '" . get_class($object) . "::$" . $this->getObjectProperty() . "'"; } @@ -259,7 +259,7 @@ class UploadFormField extends AbstractFormField { UploadHandler::getInstance()->registerFilesByField($this->getPrefixedId(), $this->values); } - $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('upload', function(IFormDocument $document, array $parameters) { + $this->getDocument()->getDataHandler()->addProcessor(new CustomFormDataProcessor('upload', function(IFormDocument $document, array $parameters) { $parameters[$this->getObjectProperty()] = $this->getValue(); $parameters[$this->getObjectProperty() . '_removedFiles'] = $this->getRemovedFiles(true); diff --git a/wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php index d2d88bf9df..61fb25ef78 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php @@ -2,8 +2,8 @@ namespace wcf\system\form\builder\field\acl; use wcf\data\IStorableObject; use wcf\system\acl\ACLHandler; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\AbstractFormField; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; use wcf\system\form\builder\IFormDocument; use wcf\system\form\builder\IObjectTypeFormNode; use wcf\system\form\builder\TObjectTypeFormNode; @@ -115,7 +115,7 @@ class AclFormField extends AbstractFormField implements IObjectTypeFormNode { /** * @inheritDoc */ - public function loadValueFromObject(IStorableObject $object) { + public function loadValue(array $data, IStorableObject $object) { $this->objectID = $object->{$object::getDatabaseTableIndexName()}; if ($this->objectID === null) { @@ -131,7 +131,7 @@ class AclFormField extends AbstractFormField implements IObjectTypeFormNode { public function populate() { parent::populate(); - $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('acl', function(IFormDocument $document, array $parameters) { + $this->getDocument()->getDataHandler()->addProcessor(new CustomFormDataProcessor('acl', function(IFormDocument $document, array $parameters) { $parameters[$this->getObjectProperty() . '_aclObjectTypeID'] = $this->getObjectType()->objectTypeID; return $parameters; diff --git a/wcfsetup/install/files/lib/system/form/builder/field/acl/simple/SimpleAclFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/acl/simple/SimpleAclFormField.class.php index f978359385..871aba2bbc 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/acl/simple/SimpleAclFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/acl/simple/SimpleAclFormField.class.php @@ -1,8 +1,8 @@ getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('i18n', function(IFormDocument $document, array $parameters) { + $this->getDocument()->getDataHandler()->addProcessor(new CustomFormDataProcessor('i18n', function(IFormDocument $document, array $parameters) { if ($this->checkDependencies() && is_array($this->getValue()) && !empty($this->getValue())) { $parameters[$this->getObjectProperty()] = $this->getValue(); } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/data/processor/CustomFormFieldDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/field/data/processor/CustomFormFieldDataProcessor.class.php deleted file mode 100644 index ab4cff40ec..0000000000 --- a/wcfsetup/install/files/lib/system/form/builder/field/data/processor/CustomFormFieldDataProcessor.class.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @package WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor - * @since 5.2 - */ -class CustomFormFieldDataProcessor implements IFormFieldDataProcessor { - /** - * processor id primarily used for error messages - * @var string - */ - protected $id; - - /** - * callable processing the data - * @var callable - */ - protected $processor; - - /** - * Initializes a new CustomFormFieldDataProcessor object. - * - * @param string $id processor id primarily used for error messages, does not have to be unique - * @param callable $processor processor callable - * - * @throws \InvalidArgumentException if either id or processor callable are invalid - */ - public function __construct($id, callable $processor) { - if (preg_match('~^[a-z][A-z0-9-]*$~', $id) !== 1) { - throw new \InvalidArgumentException("Invalid id '{$id}' given."); - } - - $this->id = $id; - - // validate processor function - $parameters = (new \ReflectionFunction($processor))->getParameters(); - if (count($parameters) !== 2) { - throw new \InvalidArgumentException( - "The processor function must expect two parameters, instead " . count($parameters) . - " parameter" . (count($parameters) !== 1 ? 's' : '') . " are expected." - ); - } - - /** @var \ReflectionClass $parameterClass */ - $parameterClass = $parameters[0]->getClass(); - if ($parameterClass === null || ($parameterClass->getName() !== IFormDocument::class && !is_subclass_of($parameterClass->getName(), IFormDocument::class))) { - throw new \InvalidArgumentException( - "The processor function's first parameter must be an instance of '" . IFormDocument::class . "', instead " . - ($parameterClass === null ? 'any' : "'" . $parameterClass->getName() . "'") . " parameter is expected." - ); - } - if (!$parameters[1]->isArray()) { - throw new \InvalidArgumentException("The processor function's second parameter must be an array."); - } - - $this->processor = $processor; - } - - /** - * @inheritDoc - */ - public function __invoke(IFormDocument $document, array $parameters) { - $parameters = call_user_func($this->processor, $document, $parameters); - - if (!is_array($parameters)) { - throw new \UnexpectedValueException("Field data processor '{$this->id}' does not return an array."); - } - - return $parameters; - } -} diff --git a/wcfsetup/install/files/lib/system/form/builder/field/data/processor/DefaultFormFieldDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/field/data/processor/DefaultFormFieldDataProcessor.class.php deleted file mode 100644 index 70b027fc5a..0000000000 --- a/wcfsetup/install/files/lib/system/form/builder/field/data/processor/DefaultFormFieldDataProcessor.class.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @package WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor - * @since 5.2 - */ -class DefaultFormFieldDataProcessor implements IFormFieldDataProcessor { - /** - * @inheritDoc - */ - public function __invoke(IFormDocument $document, array $parameters) { - $parameters['data'] = []; - - $this->getData($document, $parameters['data']); - - return $parameters; - } - - /** - * Fetches all data from the given node and stores it in the given array. - * - * @param IFormNode $node node whose data will be fetched - * @param array $data data storage - */ - protected function getData(IFormNode $node, array &$data) { - if ($node->isAvailable() && $node->checkDependencies()) { - if ($node instanceof IFormParentNode) { - foreach ($node as $childNode) { - $this->getData($childNode, $data); - } - } - else if ($node instanceof IFormField && $node->isAvailable() && $node->hasSaveValue()) { - $data[$node->getObjectProperty()] = $node->getSaveValue(); - } - } - } -} diff --git a/wcfsetup/install/files/lib/system/form/builder/field/data/processor/IFormFieldDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/field/data/processor/IFormFieldDataProcessor.class.php deleted file mode 100644 index f011d9f1b1..0000000000 --- a/wcfsetup/install/files/lib/system/form/builder/field/data/processor/IFormFieldDataProcessor.class.php +++ /dev/null @@ -1,24 +0,0 @@ - - * @package WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor - * @since 5.2 - */ -interface IFormFieldDataProcessor { - /** - * Processes the given parameters array and returns the processed version of it. - * - * @param IFormDocument $document documents whose field data is processed - * @param array $parameters parameters before processing - * @return array parameters after processing - */ - public function __invoke(IFormDocument $document, array $parameters); -} diff --git a/wcfsetup/install/files/lib/system/form/builder/field/data/processor/VoidFormFieldDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/field/data/processor/VoidFormFieldDataProcessor.class.php deleted file mode 100644 index 802d10f40e..0000000000 --- a/wcfsetup/install/files/lib/system/form/builder/field/data/processor/VoidFormFieldDataProcessor.class.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @package WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor - * @since 5.2 - */ -class VoidFormFieldDataProcessor implements IFormFieldDataProcessor { - /** - * is `true` if the property is stored in the `data` array - * @var bool - */ - protected $isDataProperty; - - /** - * name of the voided property - * @var string - */ - protected $property; - - /** - * Initializes a new CustomFormFieldDataProcessor object. - * - * @param string $property name of the voided property - * @param bool $isDataProperty is `true` if the property is stored in the `data` array - */ - public function __construct($property, $isDataProperty = true) { - $this->property = $property; - $this->isDataProperty = $isDataProperty; - } - - /** - * @inheritDoc - */ - public function __invoke(IFormDocument $document, array $parameters) { - if ($this->isDataProperty) { - if (isset($parameters['data'][$this->property])) { - unset($parameters['data'][$this->property]); - } - } - else if (isset($parameters[$this->property])) { - unset($parameters[$this->property]); - } - - return $parameters; - } -} diff --git a/wcfsetup/install/files/lib/system/form/builder/field/label/LabelFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/label/LabelFormField.class.php index c9392315f2..f1ba60d6d2 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/label/LabelFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/label/LabelFormField.class.php @@ -3,8 +3,8 @@ namespace wcf\system\form\builder\field\label; use wcf\data\IStorableObject; use wcf\data\label\group\ViewableLabelGroup; use wcf\data\label\Label; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\AbstractFormField; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; use wcf\system\form\builder\field\validation\FormFieldValidationError; use wcf\system\form\builder\IFormDocument; use wcf\system\form\builder\IObjectTypeFormNode; @@ -96,9 +96,9 @@ class LabelFormField extends AbstractFormField implements IObjectTypeFormNode { /** * @inheritDoc */ - public function loadValueFromObject(IStorableObject $object) { + public function loadValue(array $data, IStorableObject $object) { $objectTypeID = $this->getObjectType()->objectTypeID; - $objectID = $object->getObjectID(); + $objectID = $object->{$object::getDatabaseTableIndexName()}; if (!isset(static::$loadedLabels[$objectTypeID])) { static::$loadedLabels[$objectTypeID] = []; @@ -127,7 +127,7 @@ class LabelFormField extends AbstractFormField implements IObjectTypeFormNode { public function populate() { parent::populate(); - $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('label', function(IFormDocument $document, array $parameters) { + $this->getDocument()->getDataHandler()->addProcessor(new CustomFormDataProcessor('label', function(IFormDocument $document, array $parameters) { $value = $this->getValue(); // `-1` and `0` are special values that are irrlevent for saving diff --git a/wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php index 7cb5323b0b..b622bb30e5 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php @@ -1,9 +1,9 @@ {$object::getDatabaseTableIndexName()}; if ($objectID === null) { @@ -77,9 +77,8 @@ class TagFormField extends AbstractFormField implements IObjectTypeFormNode { $languageIDs = []; /** @noinspection PhpUndefinedFieldInspection */ - $objectLanguageId = $object->languageID; - if ($objectLanguageId !== null) { - $languageIDs[] = $objectLanguageId; + if (isset($data['languageID'])) { + $languageIDs[] = $data['languageID']; } $tags = TagEngine::getInstance()->getObjectTags($this->getObjectType()->objectType, $objectID, $languageIDs); @@ -98,7 +97,7 @@ class TagFormField extends AbstractFormField implements IObjectTypeFormNode { public function populate() { parent::populate(); - $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('acl', function(IFormDocument $document, array $parameters) { + $this->getDocument()->getDataHandler()->addProcessor(new CustomFormDataProcessor('acl', function(IFormDocument $document, array $parameters) { if ($this->checkDependencies() && $this->getValue() !== null && !empty($this->getValue())) { $parameters[$this->getObjectProperty()] = $this->getValue(); } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygAttachmentFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygAttachmentFormField.class.php index 4666c08808..b607e32e89 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygAttachmentFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygAttachmentFormField.class.php @@ -1,8 +1,8 @@ getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor($this->getId(), function(IFormDocument $document, array $parameters) { + $this->getDocument()->getDataHandler()->addProcessor(new CustomFormDataProcessor($this->getId(), function(IFormDocument $document, array $parameters) { if ($this->getAttachmentHandler() !== null) { $parameters[$this->getWysiwygId() . '_attachmentHandler'] = $this->getAttachmentHandler(); } diff --git a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php b/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php index b305d5afc2..75503ce1ce 100644 --- a/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/field/wysiwyg/WysiwygFormField.class.php @@ -2,8 +2,8 @@ namespace wcf\system\form\builder\field\wysiwyg; use wcf\data\IMessageQuoteAction; use wcf\data\object\type\ObjectTypeCache; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\AbstractFormField; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; use wcf\system\form\builder\field\IMaximumLengthFormField; use wcf\system\form\builder\field\IMinimumLengthFormField; use wcf\system\form\builder\field\TMaximumLengthFormField; @@ -184,7 +184,7 @@ class WysiwygFormField extends AbstractFormField implements IMaximumLengthFormFi public function populate() { parent::populate(); - $this->getDocument()->getDataHandler()->add(new CustomFormFieldDataProcessor('wysiwyg', function(IFormDocument $document, array $parameters) { + $this->getDocument()->getDataHandler()->addProcessor(new CustomFormDataProcessor('wysiwyg', function(IFormDocument $document, array $parameters) { if ($this->checkDependencies()) { $parameters[$this->getObjectProperty() . '_htmlInputProcessor'] = $this->htmlInputProcessor; } diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php index 37573696f8..4a96e29b7c 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php @@ -10,8 +10,8 @@ use wcf\system\devtools\pip\IIdempotentPackageInstallationPlugin; use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin; use wcf\system\exception\SystemException; use wcf\system\form\builder\container\IFormContainer; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\BooleanFormField; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; use wcf\system\form\builder\field\dependency\ValueFormFieldDependency; use wcf\system\form\builder\field\IntegerFormField; use wcf\system\form\builder\field\MultilineTextFormField; @@ -675,7 +675,7 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag ]); // ensure proper normalization of default value and enable options - $form->getDataHandler()->add(new CustomFormFieldDataProcessor('enableOptions', function(IFormDocument $document, array $parameters) { + $form->getDataHandler()->addProcessor(new CustomFormDataProcessor('enableOptions', function(IFormDocument $document, array $parameters) { if (isset($parameters['data']['enableoptions'])) { $parameters['data']['enableoptions'] = StringUtil::unifyNewlines($parameters['data']['enableoptions']); } diff --git a/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php index 089684f157..8330bd2586 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php @@ -12,10 +12,10 @@ use wcf\system\devtools\pip\IGuiPackageInstallationPlugin; use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin; use wcf\system\exception\SystemException; use wcf\system\form\builder\container\FormContainer; +use wcf\system\form\builder\data\processor\VoidFormDataProcessor; use wcf\system\form\builder\field\bbcode\BBCodeAttributesFormField; use wcf\system\form\builder\field\BooleanFormField; use wcf\system\form\builder\field\ClassNameFormField; -use wcf\system\form\builder\field\data\processor\VoidFormFieldDataProcessor; use wcf\system\form\builder\field\dependency\NonEmptyFormFieldDependency; use wcf\system\form\builder\field\dependency\ValueFormFieldDependency; use wcf\system\form\builder\field\IconFormField; @@ -488,7 +488,7 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug ); // discard the `iconType` value as it is only used to distinguish the two icon input fields - $form->getDataHandler()->add(new VoidFormFieldDataProcessor('iconType')); + $form->getDataHandler()->addProcessor(new VoidFormDataProcessor('iconType')); } /** diff --git a/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php index 52f18d41f7..a255e35ffb 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php @@ -7,8 +7,8 @@ use wcf\system\devtools\pip\IDevtoolsPipEntryList; use wcf\system\devtools\pip\IGuiPackageInstallationPlugin; use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin; use wcf\system\form\builder\container\FormContainer; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\ClassNameFormField; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; use wcf\system\form\builder\field\MultilineTextFormField; use wcf\system\form\builder\field\TextFormField; use wcf\system\form\builder\field\TitleFormField; @@ -189,7 +189,7 @@ class MediaProviderPackageInstallationPlugin extends AbstractXMLPackageInstallat })) ]); - $form->getDataHandler()->add(new CustomFormFieldDataProcessor('unifyNewlines', function(IFormDocument $document, array $parameters) { + $form->getDataHandler()->addProcessor(new CustomFormDataProcessor('unifyNewlines', function(IFormDocument $document, array $parameters) { $parameters['data']['regex'] = StringUtil::unifyNewlines(StringUtil::escapeCDATA($parameters['data']['regex'])); $parameters['data']['html'] = StringUtil::unifyNewlines(StringUtil::escapeCDATA($parameters['data']['html'])); diff --git a/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php index 03ad87e38d..64b7265dce 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php @@ -8,8 +8,8 @@ use wcf\data\package\Package; use wcf\system\devtools\pip\IGuiPackageInstallationPlugin; use wcf\system\exception\SystemException; use wcf\system\form\builder\container\IFormContainer; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\BooleanFormField; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; use wcf\system\form\builder\field\dependency\NonEmptyFormFieldDependency; use wcf\system\form\builder\field\dependency\ValueFormFieldDependency; use wcf\system\form\builder\field\MultilineTextFormField; @@ -222,7 +222,7 @@ class OptionPackageInstallationPlugin extends AbstractOptionPackageInstallationP ]); // ensure proper normalization of select options - $form->getDataHandler()->add(new CustomFormFieldDataProcessor('selectOptions', function(IFormDocument $document, array $parameters) { + $form->getDataHandler()->addProcessor(new CustomFormDataProcessor('selectOptions', function(IFormDocument $document, array $parameters) { if (isset($parameters['data']['selectoptions'])) { $parameters['data']['selectoptions'] = StringUtil::unifyNewlines($parameters['data']['selectoptions']); } diff --git a/wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php index 0f0f796b2f..e21378230e 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php @@ -6,7 +6,7 @@ use wcf\system\devtools\pip\IDevtoolsPipEntryList; use wcf\system\devtools\pip\IGuiPackageInstallationPlugin; use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin; use wcf\system\form\builder\container\FormContainer; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\IntegerFormField; use wcf\system\form\builder\field\ItemListFormField; use wcf\system\form\builder\field\TextFormField; @@ -216,7 +216,7 @@ class SmileyPackageInstallationPlugin extends AbstractXMLPackageInstallationPlug ]); // ensure proper normalization of template code - $form->getDataHandler()->add(new CustomFormFieldDataProcessor('templateCode', function(IFormDocument $document, array $parameters) { + $form->getDataHandler()->addProcessor(new CustomFormDataProcessor('templateCode', function(IFormDocument $document, array $parameters) { $parameters['data']['aliases'] = StringUtil::unifyNewlines(StringUtil::escapeCDATA($parameters['data']['aliases'])); return $parameters; diff --git a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php index 669a2b4b9a..01e2813f4c 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php @@ -11,16 +11,16 @@ use wcf\system\devtools\pip\IDevtoolsPipEntryList; use wcf\system\devtools\pip\IGuiPackageInstallationPlugin; use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin; use wcf\system\form\builder\container\FormContainer; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\dependency\ValueFormFieldDependency; use wcf\system\form\builder\field\IntegerFormField; +use wcf\system\form\builder\field\MultilineTextFormField; use wcf\system\form\builder\field\option\OptionFormField; +use wcf\system\form\builder\field\SingleSelectionFormField; +use wcf\system\form\builder\field\TextFormField; use wcf\system\form\builder\field\user\group\option\UserGroupOptionFormField; use wcf\system\form\builder\field\validation\FormFieldValidationError; use wcf\system\form\builder\field\validation\FormFieldValidator; -use wcf\system\form\builder\field\MultilineTextFormField; -use wcf\system\form\builder\field\SingleSelectionFormField; -use wcf\system\form\builder\field\TextFormField; use wcf\system\form\builder\IFormDocument; use wcf\system\WCF; use wcf\util\StringUtil; @@ -374,7 +374,7 @@ class TemplateListenerPackageInstallationPlugin extends AbstractXMLPackageInstal ]); // ensure proper normalization of template code - $form->getDataHandler()->add(new CustomFormFieldDataProcessor('templateCode', function(IFormDocument $document, array $parameters) { + $form->getDataHandler()->addProcessor(new CustomFormDataProcessor('templateCode', function(IFormDocument $document, array $parameters) { $parameters['data']['templatecode'] = StringUtil::unifyNewlines(StringUtil::escapeCDATA($parameters['data']['templatecode'])); return $parameters; diff --git a/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php index 641398619d..1f727a1de4 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php @@ -10,9 +10,9 @@ use wcf\data\user\option\UserOptionEditor; use wcf\system\devtools\pip\IGuiPackageInstallationPlugin; use wcf\system\exception\SystemException; use wcf\system\form\builder\container\IFormContainer; +use wcf\system\form\builder\data\processor\CustomFormDataProcessor; use wcf\system\form\builder\field\BooleanFormField; use wcf\system\form\builder\field\ClassNameFormField; -use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor; use wcf\system\form\builder\field\dependency\ValueFormFieldDependency; use wcf\system\form\builder\field\MultilineTextFormField; use wcf\system\form\builder\field\SingleSelectionFormField; @@ -320,7 +320,7 @@ class UserOptionPackageInstallationPlugin extends AbstractOptionPackageInstallat ]); // ensure proper normalization of select options - $form->getDataHandler()->add(new CustomFormFieldDataProcessor('selectOptions', function(IFormDocument $document, array $parameters) { + $form->getDataHandler()->addProcessor(new CustomFormDataProcessor('selectOptions', function(IFormDocument $document, array $parameters) { if (isset($parameters['data']['selectoptions'])) { $parameters['data']['selectoptions'] = StringUtil::unifyNewlines($parameters['data']['selectoptions']); }