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

CPS-IT / personio-jobs / 9544724083

17 Jun 2024 08:48AM UTC coverage: 3.61% (-0.03%) from 3.644%
9544724083

push

github

web-flow
Merge pull request #172 from CPS-IT/fix/work-experience

[BUGFIX] Allow `yearsOfExperience` to be empty

0 of 17 new or added lines in 2 files covered. (0.0%)

2 existing lines in 1 file now uncovered.

27 of 748 relevant lines covered (3.61%)

0.16 hits per line

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

0.0
/Classes/Configuration/Tca.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "personio_jobs".
7
 *
8
 * Copyright (C) 2023 Elias Häußler <e.haeussler@familie-redlich.de>
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 CPSIT\Typo3PersonioJobs\Configuration;
25

26
use CPSIT\Typo3PersonioJobs\Extension;
27
use TYPO3\CMS\Core\Information\Typo3Version;
28
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
29
use TYPO3\CMS\Core\Utility\GeneralUtility;
30
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
31

32
/**
33
 * Tca
34
 *
35
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
36
 * @license GPL-2.0-or-later
37
 */
38
final class Tca
39
{
40
    /**
41
     * @param list<string|\BackedEnum> $itemValues
42
     * @return list<array{string, string}>|list<array{label: string, value: string}>
43
     */
NEW
44
    public static function mapItems(
×
45
        string $tableName,
46
        string $fieldName,
47
        array $itemValues,
48
        bool $allowEmpty = false,
49
    ): array {
UNCOV
50
        $items = [];
×
51

NEW
52
        if ($allowEmpty) {
×
NEW
53
            $items[] = self::resolveItem('', '');
×
54
        }
55

56
        foreach ($itemValues as $itemValue) {
×
57
            if ($itemValue instanceof \BackedEnum) {
×
58
                $itemValue = (string)$itemValue->value;
×
59
            }
60

NEW
61
            $items[] = self::resolveItem(
×
NEW
62
                'LLL:EXT:personio_jobs/Resources/Private/Language/locallang_db.xlf:' . $tableName . '.' . $fieldName . '.' . $itemValue,
×
NEW
63
                $itemValue,
×
NEW
64
            );
×
65
        }
66

67
        return $items;
×
68
    }
69

70
    public static function addPlugin(
×
71
        string $name,
72
        string $icon = null,
73
        string $flexForm = null,
74
    ): void {
75
        $pluginSignature = self::buildPluginSignature($name);
×
76

77
        ExtensionUtility::registerPlugin(
×
78
            Extension::KEY,
×
79
            $name,
×
80
            'LLL:EXT:personio_jobs/Resources/Private/Language/locallang_db.xlf:plugins.' . lcfirst($name),
×
81
            $icon,
×
82
            'personio',
×
83
        );
×
84

85
        if ($flexForm !== null) {
×
86
            ExtensionManagementUtility::addPiFlexFormValue($pluginSignature, $flexForm);
×
87

88
            /* @phpstan-ignore-next-line */
89
            $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
×
90
        }
91
    }
92

93
    /**
94
     * @return array{label: string, value: string}|array{string, string}
95
     */
NEW
96
    private static function resolveItem(string $label, string $value): array
×
97
    {
NEW
98
        $typo3Version = (new Typo3Version())->getMajorVersion();
×
NEW
99
        $item = [
×
NEW
100
            'label' => $label,
×
NEW
101
            'value' => $value,
×
NEW
102
        ];
×
103

104
        // @todo Remove once support for TYPO3 v11 is dropped
NEW
105
        if ($typo3Version < 12) {
×
NEW
106
            $item = array_values($item);
×
107
        }
108

NEW
109
        return $item;
×
110
    }
111

UNCOV
112
    private static function buildPluginSignature(string $pluginName): string
×
113
    {
114
        $extensionName = GeneralUtility::underscoredToUpperCamelCase(Extension::KEY);
×
115

116
        return strtolower($extensionName . '_' . $pluginName);
×
117
    }
118
}
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