Move form builder’s data processors into separate namespace
authorMatthias Schmidt <gravatronics@live.com>
Thu, 3 Jan 2019 17:07:31 +0000 (18:07 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 3 Jan 2019 17:07:31 +0000 (18:07 +0100)
See #2509

26 files changed:
wcfsetup/install/files/lib/acp/form/LanguageItemAddForm.class.php
wcfsetup/install/files/lib/system/form/builder/FormDocument.class.php
wcfsetup/install/files/lib/system/form/builder/data/FormDataHandler.class.php
wcfsetup/install/files/lib/system/form/builder/data/IFormDataHandler.class.php
wcfsetup/install/files/lib/system/form/builder/field/ItemListFormField.class.php
wcfsetup/install/files/lib/system/form/builder/field/TI18nFormField.class.php
wcfsetup/install/files/lib/system/form/builder/field/TMultipleFormField.class.php
wcfsetup/install/files/lib/system/form/builder/field/WysiwygFormField.class.php
wcfsetup/install/files/lib/system/form/builder/field/acl/AclFormField.class.php
wcfsetup/install/files/lib/system/form/builder/field/acl/simple/SimpleAclFormField.class.php
wcfsetup/install/files/lib/system/form/builder/field/data/CustomFormFieldDataProcessor.class.php [deleted file]
wcfsetup/install/files/lib/system/form/builder/field/data/DefaultFormFieldDataProcessor.class.php [deleted file]
wcfsetup/install/files/lib/system/form/builder/field/data/IFormFieldDataProcessor.class.php [deleted file]
wcfsetup/install/files/lib/system/form/builder/field/data/VoidFormFieldDataProcessor.class.php [deleted file]
wcfsetup/install/files/lib/system/form/builder/field/data/processor/CustomFormFieldDataProcessor.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/form/builder/field/data/processor/DefaultFormFieldDataProcessor.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/form/builder/field/data/processor/IFormFieldDataProcessor.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/form/builder/field/data/processor/VoidFormFieldDataProcessor.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/form/builder/field/tag/TagFormField.class.php
wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/MediaProviderPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/OptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/SmileyPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/TemplateListenerPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/UserOptionPackageInstallationPlugin.class.php

index 177660c3046b7f350334423be0235055550495ad..c33362caff6d7de585f42433fca00c8697ec0037 100644 (file)
@@ -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\CustomFormFieldDataProcessor;
-use wcf\system\form\builder\field\data\VoidFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\VoidFormFieldDataProcessor;
 use wcf\system\form\builder\field\dependency\ValueFormFieldDependency;
 use wcf\system\form\builder\field\MultilineTextFormField;
 use wcf\system\form\builder\field\RadioButtonFormField;
index 04646f84d79de26d571ba8ae328312c480860b2a..005233e526ece63b6a0c5ceb73fd6eea21fec6d1 100644 (file)
@@ -3,7 +3,7 @@ namespace wcf\system\form\builder;
 use wcf\data\IStorableObject;
 use wcf\system\form\builder\data\FormDataHandler;
 use wcf\system\form\builder\data\IFormDataHandler;
-use wcf\system\form\builder\field\data\DefaultFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\DefaultFormFieldDataProcessor;
 use wcf\system\form\builder\field\IFileFormField;
 use wcf\system\form\builder\field\IFormField;
 use wcf\system\WCF;
index f75b4a40a7723be3cf6087076c44e2d4c083b6cd..ef11f01cf6c09d852bb41c704c70acceb8b82417 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 namespace wcf\system\form\builder\data;
-use wcf\system\form\builder\field\data\IFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\IFormFieldDataProcessor;
 use wcf\system\form\builder\IFormDocument;
 
 /**
index 6e98b5023e02baf9029800ac9718256ff72512a1..0a2c02ea02c7d277b670b495fad8d0628bf027cd 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 namespace wcf\system\form\builder\data;
-use wcf\system\form\builder\field\data\IFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\IFormFieldDataProcessor;
 use wcf\system\form\builder\IFormDocument;
 
 /**
index d09880bb8f6a00b17102d9259810a2de5ef1d546..f57e47abee35ee5a5e0389c384e872981c0354ff 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 namespace wcf\system\form\builder\field;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+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\util\ArrayUtil;
index 04ffde10c0ecbed93e0174812c9fd56c4a751fdd..74f394e6a81f5f0f9b808519a4d3d3b2bb08cda2 100644 (file)
@@ -2,7 +2,7 @@
 namespace wcf\system\form\builder\field;
 use wcf\data\language\item\LanguageItemList;
 use wcf\data\IStorableObject;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+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\IFormNode;
index 836fa791d3c38c46e943fcff3c97855aec6cdc87..7c6482a230014dbd6b5324ef6518c7e87f186e2d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 namespace wcf\system\form\builder\field;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
 use wcf\system\form\builder\IFormDocument;
 
 /**
index ec00e6037dd9be1c34a9f1e978d52911c5325ed6..86432b0803adefecd35e813db00987724d33e8f4 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 namespace wcf\system\form\builder\field;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+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\html\input\HtmlInputProcessor;
index 3a82a1cc31630c15f7cc8851c35f6494f3714997..e9d31e4c516f238f0d6562a17f294d479c425c9d 100644 (file)
@@ -3,7 +3,7 @@ namespace wcf\system\form\builder\field\acl;
 use wcf\data\IStorableObject;
 use wcf\system\acl\ACLHandler;
 use wcf\system\form\builder\field\AbstractFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
 use wcf\system\form\builder\field\IObjectTypeFormField;
 use wcf\system\form\builder\field\TObjectTypeFormField;
 use wcf\system\form\builder\IFormDocument;
index 25e0734a643f292b8b2ea792f36aab080000d582..ae2ddc353f6ad76460206dd09c85ba67e348f347 100644 (file)
@@ -2,7 +2,7 @@
 namespace wcf\system\form\builder\field\acl\simple;
 use wcf\system\acl\simple\SimpleAclHandler;
 use wcf\system\form\builder\field\AbstractFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
 use wcf\system\form\builder\IFormDocument;
 
 /**
diff --git a/wcfsetup/install/files/lib/system/form/builder/field/data/CustomFormFieldDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/field/data/CustomFormFieldDataProcessor.class.php
deleted file mode 100644 (file)
index f50ffe8..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-<?php
-namespace wcf\system\form\builder\field\data;
-use wcf\system\form\builder\IFormDocument;
-
-/**
- * Field data processor implementation that supports a custom processor callable.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2018 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Form\Builder\Field\Data
- * @since      3.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/DefaultFormFieldDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/field/data/DefaultFormFieldDataProcessor.class.php
deleted file mode 100644 (file)
index 48fadfc..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-namespace wcf\system\form\builder\field\data;
-use wcf\system\form\builder\field\IFormField;
-use wcf\system\form\builder\IFormDocument;
-use wcf\system\form\builder\IFormNode;
-use wcf\system\form\builder\IFormParentNode;
-
-/**
- * Default field data processor that maps the form fields to entries in
- * the `data` sub-array with the field ids as array keys and field values
- * as array values.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2018 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Form\Builder\Field\Data
- * @since      3.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->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/IFormFieldDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/field/data/IFormFieldDataProcessor.class.php
deleted file mode 100644 (file)
index 20683fe..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-namespace wcf\system\form\builder\field\data;
-use wcf\system\form\builder\IFormDocument;
-
-/**
- * Represents a data processor for form fields that populates or manipulates the
- * parameters array passed to the constructor of a database object action.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2018 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Form\Builder\Field\Data
- * @since      3.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/VoidFormFieldDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/field/data/VoidFormFieldDataProcessor.class.php
deleted file mode 100644 (file)
index 1059efb..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-namespace wcf\system\form\builder\field\data;
-use wcf\system\form\builder\IFormDocument;
-
-/**
- * Field data processor implementation that voids a certain data property.
- * 
- * @author     Matthias Schmidt
- * @copyright  2001-2018 WoltLab GmbH
- * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
- * @package    WoltLabSuite\Core\System\Form\Builder\Field\Data
- * @since      3.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/data/processor/CustomFormFieldDataProcessor.class.php b/wcfsetup/install/files/lib/system/form/builder/field/data/processor/CustomFormFieldDataProcessor.class.php
new file mode 100644 (file)
index 0000000..6ffb6f3
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+namespace wcf\system\form\builder\field\data\processor;
+use wcf\system\form\builder\IFormDocument;
+
+/**
+ * Field data processor implementation that supports a custom processor callable.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2018 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor
+ * @since      3.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
new file mode 100644 (file)
index 0000000..c3b17eb
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+namespace wcf\system\form\builder\field\data\processor;
+use wcf\system\form\builder\field\IFormField;
+use wcf\system\form\builder\IFormDocument;
+use wcf\system\form\builder\IFormNode;
+use wcf\system\form\builder\IFormParentNode;
+
+/**
+ * Default field data processor that maps the form fields to entries in
+ * the `data` sub-array with the field ids as array keys and field values
+ * as array values.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2018 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor
+ * @since      3.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->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
new file mode 100644 (file)
index 0000000..a179fc9
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+namespace wcf\system\form\builder\field\data\processor;
+use wcf\system\form\builder\IFormDocument;
+
+/**
+ * Represents a data processor for form fields that populates or manipulates the
+ * parameters array passed to the constructor of a database object action.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2018 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor
+ * @since      3.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
new file mode 100644 (file)
index 0000000..50331c2
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+namespace wcf\system\form\builder\field\data\processor;
+use wcf\system\form\builder\IFormDocument;
+
+/**
+ * Field data processor implementation that voids a certain data property.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2018 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor
+ * @since      3.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;
+       }
+}
index 08cb22e1957d1297e65ccd71cdeeb921235246f0..4e419d211a5ae6087a24f87a38600cb0bff1a2dc 100644 (file)
@@ -3,7 +3,7 @@ namespace wcf\system\form\builder\field\tag;
 use wcf\data\tag\Tag;
 use wcf\data\IStorableObject;
 use wcf\system\form\builder\field\AbstractFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
 use wcf\system\form\builder\field\IObjectTypeFormField;
 use wcf\system\form\builder\field\TObjectTypeFormField;
 use wcf\system\form\builder\IFormDocument;
index d8eee8223afa590431a08335f7ad29faea4b4428..9721e4944d8696cb10da21db170ce9b30ac3c2cc 100644 (file)
@@ -11,7 +11,7 @@ use wcf\system\devtools\pip\TXmlGuiPackageInstallationPlugin;
 use wcf\system\exception\SystemException;
 use wcf\system\form\builder\container\IFormContainer;
 use wcf\system\form\builder\field\BooleanFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+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;
index d9265f2bf1ce66d7fbf036cb8629c81bcd46cb1b..233278c4bbc57a3cca80c4e153f245e53246e067 100644 (file)
@@ -15,7 +15,7 @@ use wcf\system\form\builder\container\FormContainer;
 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\VoidFormFieldDataProcessor;
+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;
index 16145a99d322eff21135795ccc59f689273c8c1c..319c1ec6a33a876b343a84ba7c6442bcfd995a02 100644 (file)
@@ -8,7 +8,7 @@ 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\ClassNameFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+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;
index 85c7f366c1e3229207a48fadc5d235870c3f7fbc..f71c35297b7c3a7bace0a2a71973dd75e34a6136 100644 (file)
@@ -9,7 +9,7 @@ use wcf\system\devtools\pip\IGuiPackageInstallationPlugin;
 use wcf\system\exception\SystemException;
 use wcf\system\form\builder\container\IFormContainer;
 use wcf\system\form\builder\field\BooleanFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+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;
index d9d587e44c3822cdf07e04c89ad0b5a759180fe0..04e6b245130b7acff633ecce1b59458985389003 100644 (file)
@@ -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\CustomFormFieldDataProcessor;
+use wcf\system\form\builder\field\data\processor\CustomFormFieldDataProcessor;
 use wcf\system\form\builder\field\IntegerFormField;
 use wcf\system\form\builder\field\ItemListFormField;
 use wcf\system\form\builder\field\TextFormField;
index 1d11a9c53c3399ebfddf02eda0f290deb756d683..5f2188d3e6d0468895ba62d87fae0ace14ee2c53 100644 (file)
@@ -11,7 +11,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\CustomFormFieldDataProcessor;
+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\option\OptionFormField;
index 1c9b3df7e9b0ac3fa77a32753bbf8ae6d1d8670f..05dd37aefa231d256954a3ed95a4f3c00d7fb1ce 100644 (file)
@@ -12,7 +12,7 @@ use wcf\system\exception\SystemException;
 use wcf\system\form\builder\container\IFormContainer;
 use wcf\system\form\builder\field\BooleanFormField;
 use wcf\system\form\builder\field\ClassNameFormField;
-use wcf\system\form\builder\field\data\CustomFormFieldDataProcessor;
+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;