2 namespace wcf\system\form\builder\field\data\processor;
3 use wcf\system\form\builder\field\IFormField;
4 use wcf\system\form\builder\IFormDocument;
5 use wcf\system\form\builder\IFormNode;
6 use wcf\system\form\builder\IFormParentNode;
9 * Default field data processor that maps the form fields to entries in
10 * the `data` sub-array with the field ids as array keys and field values
13 * @author Matthias Schmidt
14 * @copyright 2001-2018 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\Form\Builder\Field\Data\Processor
19 class DefaultFormFieldDataProcessor implements IFormFieldDataProcessor {
23 public function __invoke(IFormDocument $document, array $parameters) {
24 $parameters['data'] = [];
26 $this->getData($document, $parameters['data']);
32 * Fetches all data from the given node and stores it in the given array.
34 * @param IFormNode $node node whose data will be fetched
35 * @param array $data data storage
37 protected function getData(IFormNode $node, array &$data) {
38 if ($node->checkDependencies()) {
39 if ($node instanceof IFormParentNode) {
40 foreach ($node as $childNode) {
41 $this->getData($childNode, $data);
44 else if ($node instanceof IFormField && $node->isAvailable() && $node->hasSaveValue()) {
45 $data[$node->getObjectProperty()] = $node->getSaveValue();