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

CPS-IT / personio-jobs / 9544966933

17 Jun 2024 09:05AM UTC coverage: 3.61%. Remained the same
9544966933

Pull #174

github

web-flow
Merge b40d57a17 into e176f9c66
Pull Request #174: [TASK] Avoid generic `@phpstan-ignore-*` annotations

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
     */
44
    public static function mapItems(
×
45
        string $tableName,
46
        string $fieldName,
47
        array $itemValues,
48
        bool $allowEmpty = false,
49
    ): array {
50
        $items = [];
×
51

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

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

61
            $items[] = self::resolveItem(
×
62
                'LLL:EXT:personio_jobs/Resources/Private/Language/locallang_db.xlf:' . $tableName . '.' . $fieldName . '.' . $itemValue,
×
63
                $itemValue,
×
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
            $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
×
89
        }
90
    }
91

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

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

108
        return $item;
×
109
    }
110

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

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