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

CPS-IT / personio-jobs / 15388656121

02 Jun 2025 09:22AM UTC coverage: 3.649%. Remained the same
15388656121

push

github

web-flow
Merge pull request #230 from CPS-IT/task/phpstan

[TASK] Use `phpstan-{deprecated,strict}-rules` packages

0 of 2 new or added lines in 1 file covered. (0.0%)

27 of 740 relevant lines covered (3.65%)

0.16 hits per line

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

0.0
/Classes/Helper/SlugHelper.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\Helper;
25

26
use TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory;
27
use TYPO3\CMS\Core\DataHandling\SlugHelper as CoreSlugHelper;
28
use TYPO3\CMS\Core\Utility\GeneralUtility;
29

30
/**
31
 * SlugHelper
32
 *
33
 * @author Elias Häußler <e.haeussler@familie-redlich.de>
34
 * @license GPL-2.0-or-later
35
 */
36
final class SlugHelper
37
{
38
    /**
39
     * @param array<string, mixed> $record
40
     */
41
    public static function generateSlug(string $tableName, array $record, string $slugFieldName = 'slug'): ?string
×
42
    {
43
        $fieldConfiguration = $GLOBALS['TCA'][$tableName]['columns'][$slugFieldName]['config'] ?? null;
×
44

45
        // Early return if slug field is not configured
46
        if (!is_array($fieldConfiguration)) {
×
47
            return null;
×
48
        }
49

50
        // Get field configuration
51
        $evalInfo = GeneralUtility::trimExplode(',', (string)($fieldConfiguration['eval'] ?? ''), true);
×
52

53
        // Initialize Slug helper
54
        $slugHelper = GeneralUtility::makeInstance(CoreSlugHelper::class, $tableName, $slugFieldName, $fieldConfiguration);
×
55

56
        // Generate slug
57
        $slug = $slugHelper->generate($record, (int)$record['pid']);
×
58
        $state = RecordStateFactory::forName($tableName)->fromArray($record, (int)$record['pid'], (int)$record['uid']);
×
59

60
        // Assure slug is unique as configured
NEW
61
        if (in_array('uniqueInSite', $evalInfo, true)) {
×
62
            $slug = $slugHelper->buildSlugForUniqueInSite($slug, $state);
×
NEW
63
        } elseif (in_array('uniqueInPid', $evalInfo, true)) {
×
64
            $slug = $slugHelper->buildSlugForUniqueInPid($slug, $state);
×
65
        }
66

67
        return $slug;
×
68
    }
69
}
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