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

Yoast / Yoast-SEO-for-TYPO3 / 13327579701

14 Feb 2025 10:43AM UTC coverage: 1.276%. First build
13327579701

push

github

web-flow
Merge pull request #597 from Yoast/feature/v11

[FEATURE] Release 11.0.0

21 of 894 new or added lines in 76 files covered. (2.35%)

35 of 2744 relevant lines covered (1.28%)

0.04 hits per line

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

0.0
/Classes/Utility/YoastUtility.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace YoastSeoForTypo3\YoastSeo\Utility;
6

7
use TYPO3\CMS\Backend\Utility\BackendUtility;
8
use TYPO3\CMS\Core\Database\ConnectionPool;
9
use TYPO3\CMS\Core\Utility\GeneralUtility;
10

11
class YoastUtility
12
{
13
    protected const COLUMN_NAME_FOCUSKEYWORD = 'tx_yoastseo_focuskeyword';
14

15
    /**
16
     * @param array<string, mixed>|null $configuration
17
     * @return int[]
18
     */
19
    public static function getAllowedDoktypes(?array $configuration = null): array
20
    {
21
        $allowedDoktypes = array_map(function ($doktype) {
×
22
            return (int)$doktype;
×
23
        }, array_values((array)($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['yoast_seo']['allowedDoktypes'] ?? [])));
×
NEW
24
        $allowedDoktypes = array_unique($allowedDoktypes);
×
25

26
        if (isset($configuration['allowedDoktypes'])
×
27
            && is_array($configuration['allowedDoktypes'])
×
28
        ) {
29
            foreach ($configuration['allowedDoktypes'] as $doktype) {
×
30
                if (!in_array($doktype, $allowedDoktypes)) {
×
31
                    $allowedDoktypes[] = (int)$doktype;
×
32
                }
33
            }
34
        }
35

36
        return $allowedDoktypes ?: [1];
×
37
    }
38

39
    /**
40
     * @param array<string, mixed>|null $configuration
41
     */
42
    public static function getAllowedDoktypesList(?array $configuration = null): string
43
    {
44
        return implode(',', self::getAllowedDoktypes($configuration));
×
45
    }
46

47
    public static function getFocusKeywordOfRecord(int $uid, string $table = 'pages'): ?string
48
    {
49
        $focusKeyword = '';
×
50
        if (empty((int)$uid)) {
×
51
            return '';
×
52
        }
53

54
        $record = BackendUtility::getRecord($table, $uid);
×
55
        if (\is_array($record) && array_key_exists(self::COLUMN_NAME_FOCUSKEYWORD, $record)) {
×
56
            $focusKeyword = $record[self::COLUMN_NAME_FOCUSKEYWORD];
×
57
        }
58
        return $focusKeyword;
×
59
    }
60

61
    /**
62
     * @return array<string, array{keyword: string, synonyms: string}>
63
     */
64
    public static function getRelatedKeyphrases(string $parentTable, int $parentId): array
65
    {
66
        $config = [];
×
67
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
×
68
            'tx_yoastseo_related_focuskeyword'
×
69
        );
×
70
        $relatedKeyphrases = $queryBuilder->select('*')
×
71
            ->from('tx_yoastseo_related_focuskeyword')
×
72
            ->where(
×
73
                $queryBuilder->expr()->eq('tablenames', $queryBuilder->createNamedParameter($parentTable)),
×
74
                $queryBuilder->expr()->eq('uid_foreign', $parentId)
×
75
            )
×
76
            ->executeQuery()
×
77
            ->fetchAllAssociative();
×
78

79
        foreach ($relatedKeyphrases as $relatedKeyphrase) {
×
80
            $config['rk' . (int)$relatedKeyphrase['uid']] = [
×
81
                'keyword' => (string)$relatedKeyphrase['keyword'],
×
NEW
82
                'synonyms' => (string)$relatedKeyphrase['synonyms'],
×
83
            ];
×
84
        }
85

86
        return $config;
×
87
    }
88

89
    /**
90
     * Fix absolute url when site configuration has '/' as base
91
     *
92
     * @param string $url
93
     * @return string
94
     */
95
    public static function fixAbsoluteUrl(string $url): string
96
    {
97
        if (str_starts_with($url, '/')) {
×
98
            $url = GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . $url;
×
99
        }
100
        return $url;
×
101
    }
102
}
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