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

Yoast / Yoast-SEO-for-TYPO3 / 21521134747

30 Jan 2026 03:30PM UTC coverage: 0.866% (-0.4%) from 1.275%
21521134747

push

github

RinyVT
[FEATURE] Version 12.0.0, added v14 support, removed v11 support including php8.0 and php8.1, rewrote backend javascript functionality to typescript and webcomponents

0 of 550 new or added lines in 53 files covered. (0.0%)

33 existing lines in 21 files now uncovered.

23 of 2657 relevant lines covered (0.87%)

0.03 hits per line

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

0.0
/Classes/Service/SnippetPreview/SnippetPreviewConfigurationBuilder.php
1
<?php
2

3
/**
4
 * This file is part of the "yoast_seo" extension for TYPO3 CMS.
5
 *
6
 * For the full copyright and license information, please read the
7
 * LICENSE.txt file that was distributed with this source code.
8
 */
9

10
declare(strict_types=1);
11

12
namespace YoastSeoForTypo3\YoastSeo\Service\SnippetPreview;
13

14
use YoastSeoForTypo3\YoastSeo\Service\SiteService;
15
use YoastSeoForTypo3\YoastSeo\Utility\YoastUtility;
16

17
class SnippetPreviewConfigurationBuilder
18
{
19
    protected string $titleField = 'title';
20
    protected string $pageTitleField = 'title';
21
    protected string $descriptionField = 'description';
22
    protected string $focusKeywordField = 'tx_yoastseo_focuskeyword';
23
    protected string $focusKeywordSynonymsField = 'tx_yoastseo_focuskeyword_synonyms';
24
    protected string $cornerstoneField = 'tx_yoastseo_cornerstone';
25
    protected string $relatedKeyphrases = 'tx_yoastseo_focuskeyword_related';
26

27
    public function __construct(
28
        protected SiteService $siteService
NEW
29
    ) {}
×
30

31
    /**
32
     * @param array<string, mixed> $data
33
     * @return array<string, mixed>
34
     */
35
    public function buildConfigurationForTCA(array $data, int $languageId): array
36
    {
37
        $this->initializeFields($data);
×
38

39
        return [
×
40
            'TCA' => 1,
×
41
            'data' => [
×
42
                'table' => $data['tableName'],
×
43
                'uid' => (int)($data['defaultLanguagePageRow']['uid'] ?? $data['databaseRow']['uid']),
×
44
                'pid' => (int)$data['databaseRow']['pid'],
×
45
                'languageId' => $languageId,
×
NEW
46
                'websiteTitle' => $this->siteService->getWebsiteTitle(
×
NEW
47
                    (int)($data['tableName'] === 'pages' ? $data['databaseRow']['uid'] : $data['databaseRow']['pid']),
×
NEW
48
                    $languageId
×
NEW
49
                ),
×
50
            ],
×
51
            'fieldSelectors' => $this->buildFieldSelectors($data),
×
NEW
52
            'relatedKeyphrases' => YoastUtility::getRelatedKeyphrases(
×
NEW
53
                $data['tableName'],
×
NEW
54
                (int)$data['databaseRow']['uid']
×
NEW
55
            ),
×
UNCOV
56
        ];
×
57
    }
58

59
    /**
60
     * @param array<string, mixed> $currentPage
61
     * @return array<string, mixed>
62
     */
63
    public function buildConfigurationForPage(int $pageId, array $currentPage, int $languageId): array
64
    {
65
        return [
×
66
            'data' => [
×
67
                'table' => 'pages',
×
68
                'uid' => $pageId,
×
69
                'pid' => $currentPage['pid'],
×
70
                'languageId' => $languageId,
×
NEW
71
                'websiteTitle' => $this->siteService->getWebsiteTitle($pageId, $languageId),
×
72
            ],
×
73
            'fieldSelectors' => [],
×
74
        ];
×
75
    }
76

77
    /**
78
     * @param array<string, mixed> $data
79
     * @return array<string, string>
80
     */
81
    protected function buildFieldSelectors(array $data): array
82
    {
83
        return [
×
84
            'title' => $this->getFieldSelector($data, $this->titleField),
×
85
            'pageTitle' => $this->getFieldSelector($data, $this->pageTitleField),
×
86
            'description' => $this->getFieldSelector($data, $this->descriptionField),
×
87
            'focusKeyword' => $this->getFieldSelector($data, $this->focusKeywordField),
×
88
            'focusKeywordSynonyms' => $this->getFieldSelector($data, $this->focusKeywordSynonymsField),
×
89
            'cornerstone' => $this->getFieldSelector($data, $this->cornerstoneField),
×
90
            'relatedKeyword' => $this->getFieldSelector($data, $this->relatedKeyphrases, true),
×
91
        ];
×
92
    }
93

94
    /**
95
     * @param array<string, mixed> $data
96
     */
97
    protected function getFieldSelector(array $data, string $field, bool $id = false): string
98
    {
99
        if ($id === true) {
×
100
            $element = 'data-' . $data['vanillaUid'] . '-' . $data['tableName'] . '-' . $data['vanillaUid'] . '-' . $field;
×
101
        } else {
102
            $element = 'data' . str_replace('tx_yoastseo_snippetpreview', $field, $data['elementBaseName']);
×
103
        }
104

105
        return $element;
×
106
    }
107

108
    /**
109
     * @param array<string, mixed> $data
110
     */
111
    protected function initializeFields(array $data): void
112
    {
113
        foreach (['titleField', 'pageTitleField', 'descriptionField'] as $field) {
×
114
            if (!empty($data['parameterArray']['fieldConf']['config']['settings'][$field] ?? '')) {
×
115
                $this->$field = $data['parameterArray']['fieldConf']['config']['settings'][$field];
×
116
            }
117
        }
118
    }
119
}
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