• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eliashaeussler / typo3-form-consent / 20137980723

11 Dec 2025 03:16PM UTC coverage: 95.51% (+2.3%) from 93.23%
20137980723

push

github

web-flow
Merge pull request #436 from eliashaeussler/task/drop-typo3-v12

30 of 39 new or added lines in 6 files covered. (76.92%)

16 existing lines in 3 files now uncovered.

787 of 824 relevant lines covered (95.51%)

15.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

78.79
/Classes/Form/Element/ConsentDataElement.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "form_consent".
7
 *
8
 * Copyright (C) 2021-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\Typo3FormConsent\Form\Element;
25

26
use TYPO3\CMS\Backend;
27
use TYPO3\CMS\Extbase;
28

29
/**
30
 * ConsentDataElement
31
 *
32
 * @author Elias Häußler <elias@haeussler.dev>
33
 * @license GPL-2.0-or-later
34
 */
35
final class ConsentDataElement extends Backend\Form\Element\AbstractFormElement
36
{
37
    /**
38
     * @return array<string, mixed>
39
     */
40
    public function render(): array
1✔
41
    {
42
        $result = $this->initializeResultArray();
1✔
43

44
        if ($this->data['command'] === 'new') {
1✔
UNCOV
45
            $elementHtml = $this->renderAlert('newRecord');
×
46
        } else {
47
            $elementHtml = $this->renderRecordDataHtml();
1✔
48
        }
49

50
        return $this->renderFormElement($result, $elementHtml);
1✔
51
    }
52

53
    private function renderRecordDataHtml(): string
1✔
54
    {
55
        $row = $this->data['databaseRow'] ?? [];
1✔
56
        $formData = (string)$row['data'];
1✔
57
        $formData = json_decode($formData, true) ?? [];
1✔
58
        $title = $this->getLanguageService()->sL('LLL:EXT:form_consent/Resources/Private/Language/locallang_be.xlf:form.data.header');
1✔
59

60
        if (!\is_array($formData) || $formData === []) {
1✔
UNCOV
61
            return $this->renderAlert('noDataAvailable');
×
62
        }
63

64
        return Extbase\Utility\DebuggerUtility::var_dump($formData, $title, 8, false, false, true);
1✔
65
    }
66

67
    /**
68
     * @param array<string, mixed> $result
69
     * @return array<string, mixed>
70
     */
71
    private function renderFormElement(array $result, string $elementHtml): array
1✔
72
    {
73
        $fieldInformationResult = $this->renderFieldInformation();
1✔
74
        $fieldInformationHtml = $fieldInformationResult['html'];
1✔
75
        $result = $this->mergeChildReturnIntoExistingResult($result, $fieldInformationResult, false);
1✔
76

77
        $html = [];
78
        $html[] = '<div class="formengine-field-item t3js-formengine-field-item">';
1✔
79
        $html[] =   $fieldInformationHtml;
1✔
80
        $html[] =   '<div class="form-wizards-wrap">';
1✔
81
        $html[] =     '<div class="form-wizards-element">';
1✔
82
        $html[] =       $elementHtml;
1✔
83
        $html[] =     '</div>';
1✔
84
        $html[] =   '</div>';
1✔
85
        $html[] = '</div>';
1✔
86

87
        $result['html'] = implode(PHP_EOL, $html);
1✔
88

89
        return $result;
1✔
90
    }
91

UNCOV
92
    private function renderAlert(string $localizationKey): string
×
93
    {
94
        $html = [];
UNCOV
95
        $html[] = '<div class="alert alert-info alert-message" role="alert">';
×
96
        $html[] =     $this->getLanguageService()->sL('LLL:EXT:form_consent/Resources/Private/Language/locallang_be.xlf:message.' . $localizationKey);
×
97
        $html[] = '</div>';
×
98

UNCOV
99
        return implode(PHP_EOL, $html);
×
100
    }
101
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc