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

Yoast / Yoast-SEO-for-TYPO3 / 24723291290

21 Apr 2026 12:50PM UTC coverage: 10.457% (+9.2%) from 1.275%
24723291290

push

github

web-flow
Merge pull request #632 from Yoast/feature/yoast-v12

[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

40 of 806 new or added lines in 69 files covered. (4.96%)

40 existing lines in 23 files now uncovered.

284 of 2716 relevant lines covered (10.46%)

0.29 hits per line

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

0.0
/Classes/Service/TcaService.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;
13

14
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
15
use YoastSeoForTypo3\YoastSeo\Constants\TableNames;
16

17
class TcaService
18
{
19
    protected const LL_PREFIX_TCA = 'LLL:EXT:yoast_seo/Resources/Private/Language/TCA.xlf:';
20
    protected const LL_PREFIX_BACKEND = 'LLL:EXT:yoast_seo/Resources/Private/Language/BackendModule.xlf:';
21

22
    protected string $table = '';
23
    protected string $types = '';
24
    protected string $descriptionField = '';
25

26
    public function addYoastFields(string $table, string $types, string $descriptionField = 'description'): void
27
    {
28
        $this->table = $table;
×
29
        $this->types = $types;
×
30
        $this->descriptionField = $descriptionField;
×
31

32
        $this->addDefaultFields();
×
NEW
33
        $this->addSocialPreviewFields();
×
34

35
        $this->addPalettes();
×
36
        $this->addToTypes();
×
37
    }
38

39
    protected function addDefaultFields(): void
40
    {
41
        $columns = [
×
42
            'tx_yoastseo_snippetpreview' => [
×
43
                'label' => self::LL_PREFIX_BACKEND . 'snippetPreview',
×
44
                'exclude' => true,
×
NEW
45
                'displayCond' => [
×
NEW
46
                    'OR' => [
×
NEW
47
                        'FIELD:tx_yoastseo_hide_snippet_preview:REQ:false',
×
NEW
48
                        'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
NEW
49
                    ],
×
NEW
50
                ],
×
51
                'config' => [
×
52
                    'type' => 'none',
×
53
                    'renderType' => 'snippetPreview',
×
54
                    'settings' => [
×
55
                        'titleField' => 'seo_title',
×
56
                        'descriptionField' => $this->descriptionField,
×
57
                    ],
×
58
                ],
×
59
            ],
×
60
            'tx_yoastseo_readability_analysis' => [
×
61
                'label' => self::LL_PREFIX_BACKEND . 'analysis',
×
62
                'exclude' => true,
×
NEW
63
                'displayCond' => 'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
64
                'config' => [
×
65
                    'type' => 'none',
×
66
                    'renderType' => 'readabilityAnalysis',
×
67
                ],
×
68
            ],
×
69
            'tx_yoastseo_focuskeyword' => [
×
70
                'label' => self::LL_PREFIX_BACKEND . 'seoFocusKeyword',
×
71
                'exclude' => true,
×
NEW
72
                'displayCond' => 'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
73
                'config' => [
×
74
                    'type' => 'input',
×
75
                ],
×
76
            ],
×
77
            'tx_yoastseo_focuskeyword_analysis' => [
×
78
                'label' => self::LL_PREFIX_BACKEND . 'analysis',
×
79
                'exclude' => true,
×
NEW
80
                'displayCond' => 'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
81
                'config' => [
×
82
                    'type' => 'none',
×
83
                    'renderType' => 'focusKeywordAnalysis',
×
84
                    'settings' => [
×
85
                        'focusKeywordField' => 'tx_yoastseo_focuskeyword',
×
86
                    ],
×
87
                ],
×
88
            ],
×
89
            'tx_yoastseo_cornerstone' => [
×
90
                'label' => '',
×
91
                'exclude' => true,
×
NEW
92
                'displayCond' => 'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
93
                'config' => [
×
94
                    'type' => 'input',
×
95
                    'default' => 0,
×
96
                    'renderType' => 'cornerstone',
×
97
                ],
×
98
            ],
×
99
            'tx_yoastseo_score_readability' => [
×
100
                'label' => '',
×
101
                'exclude' => false,
×
102
                'config' => [
×
103
                    'type' => 'passthrough',
×
104
                ],
×
105
            ],
×
106
            'tx_yoastseo_score_seo' => [
×
107
                'label' => '',
×
108
                'exclude' => false,
×
109
                'config' => [
×
110
                    'type' => 'passthrough',
×
111
                ],
×
112
            ],
×
113
            'tx_yoastseo_focuskeyword_related' => [
×
114
                'label' => self::LL_PREFIX_TCA . 'pages.fields.tx_yoastseo_focuskeyword_related',
×
115
                'exclude' => true,
×
NEW
116
                'displayCond' => 'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
117
                'config' => [
×
118
                    'type' => 'inline',
×
NEW
119
                    'foreign_table' => TableNames::RELATED_FOCUSKEYWORD,
×
120
                    'foreign_field' => 'uid_foreign',
×
121
                    'foreign_table_field' => 'tablenames',
×
122
                    'maxitems' => 5,
×
123
                ],
×
124
            ],
×
125
            'tx_yoastseo_insights' => [
×
126
                'exclude' => true,
×
NEW
127
                'displayCond' => 'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
128
                'config' => [
×
129
                    'type' => 'none',
×
130
                    'renderType' => 'insights',
×
131
                ],
×
132
            ],
×
133
            'tx_yoastseo_focuskeyword_synonyms' => [
×
134
                'label' => self::LL_PREFIX_TCA . 'synonyms',
×
135
                'exclude' => true,
×
NEW
136
                'displayCond' => 'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
137
                'config' => [
×
138
                    'type' => 'input',
×
139
                ],
×
140
            ],
×
141
            'tx_yoastseo_robots_noimageindex' => [
×
142
                'label' => self::LL_PREFIX_TCA . 'pages.fields.robots.noimageindex',
×
143
                'exclude' => true,
×
144
                'config' => [
×
145
                    'type' => 'check',
×
146
                    'renderType' => 'checkboxToggle',
×
147
                    'items' => $this->getInvertedCheckbox(),
×
148
                ],
×
149
            ],
×
150
            'tx_yoastseo_robots_noarchive' => [
×
151
                'label' => self::LL_PREFIX_TCA . 'pages.fields.robots.noarchive',
×
152
                'exclude' => true,
×
153
                'config' => [
×
154
                    'type' => 'check',
×
155
                    'renderType' => 'checkboxToggle',
×
156
                    'items' => $this->getInvertedCheckbox(),
×
157
                ],
×
158
            ],
×
159
            'tx_yoastseo_robots_nosnippet' => [
×
160
                'label' => self::LL_PREFIX_TCA . 'pages.fields.robots.nosnippet',
×
161
                'exclude' => true,
×
162
                'config' => [
×
163
                    'type' => 'check',
×
164
                    'renderType' => 'checkboxToggle',
×
165
                    'items' => $this->getInvertedCheckbox(),
×
166
                ],
×
167
            ],
×
168
        ];
×
NEW
169
        if ($this->table === TableNames::PAGES) {
×
NEW
170
            $columns['tx_yoastseo_disable_analysis'] = [
×
NEW
171
                'label' => self::LL_PREFIX_BACKEND . 'disableAnalysis',
×
NEW
172
                'exclude' => true,
×
NEW
173
                'onChange' => 'reload',
×
NEW
174
                'config' => [
×
NEW
175
                    'type' => 'check',
×
NEW
176
                ],
×
NEW
177
            ];
×
178
            $columns['tx_yoastseo_hide_snippet_preview'] = [
×
179
                'label' => self::LL_PREFIX_BACKEND . 'hideSnippetPreview',
×
180
                'exclude' => true,
×
181
                'config' => [
×
182
                    'type' => 'check',
×
183
                ],
×
184
            ];
×
185
        }
186
        ExtensionManagementUtility::addTCAcolumns(
×
187
            $this->table,
×
188
            $columns
×
189
        );
×
190
    }
191

192
    protected function addSocialPreviewFields(): void
193
    {
NEW
194
        ExtensionManagementUtility::addTCAcolumns(
×
NEW
195
            $this->table,
×
NEW
196
            [
×
NEW
197
                'tx_yoastseo_facebook_preview' => [
×
NEW
198
                    'label' => self::LL_PREFIX_TCA . 'pages.fields.tx_yoastseo_facebook_preview',
×
NEW
199
                    'exclude' => true,
×
NEW
200
                    'displayCond' => 'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
NEW
201
                    'config' => [
×
NEW
202
                        'type' => 'none',
×
NEW
203
                        'renderType' => 'facebookPreview',
×
NEW
204
                    ],
×
NEW
205
                ],
×
NEW
206
                'tx_yoastseo_twitter_preview' => [
×
NEW
207
                    'label' => self::LL_PREFIX_TCA . 'pages.fields.tx_yoastseo_twitter_preview',
×
NEW
208
                    'exclude' => true,
×
NEW
209
                    'displayCond' => 'FIELD:tx_yoastseo_disable_analysis:REQ:false',
×
NEW
210
                    'config' => [
×
NEW
211
                        'type' => 'none',
×
NEW
212
                        'renderType' => 'twitterPreview',
×
NEW
213
                    ],
×
NEW
214
                ],
×
NEW
215
            ]
×
NEW
216
        );
×
217

NEW
218
        ExtensionManagementUtility::addFieldsToPalette(
×
NEW
219
            TableNames::PAGES,
×
NEW
220
            'opengraph',
×
NEW
221
            'tx_yoastseo_facebook_preview,--linebreak--',
×
NEW
222
            'before:og_title'
×
NEW
223
        );
×
224

NEW
225
        ExtensionManagementUtility::addFieldsToPalette(
×
NEW
226
            TableNames::PAGES,
×
NEW
227
            'twittercards',
×
NEW
228
            'tx_yoastseo_twitter_preview,--linebreak--',
×
NEW
229
            'before:twitter_title'
×
NEW
230
        );
×
231
    }
232

233
    protected function addPalettes(): void
234
    {
235
        ExtensionManagementUtility::addFieldsToPalette(
×
236
            $this->table,
×
237
            'seo',
×
238
            '--linebreak--, tx_yoastseo_snippetpreview, --linebreak--',
×
239
            'before: seo_title'
×
240
        );
×
241

242
        ExtensionManagementUtility::addFieldsToPalette(
×
243
            $this->table,
×
244
            'seo',
×
245
            '--linebreak--, ' . $this->descriptionField . ', --linebreak--, tx_yoastseo_cornerstone',
×
246
            'after: seo_title'
×
247
        );
×
248

249
        ExtensionManagementUtility::addFieldsToPalette(
×
250
            $this->table,
×
251
            'yoast-readability',
×
252
            '--linebreak--, tx_yoastseo_readability_analysis'
×
253
        );
×
254

255
        ExtensionManagementUtility::addFieldsToPalette(
×
256
            $this->table,
×
257
            'yoast-focuskeyword',
×
258
            '--linebreak--, tx_yoastseo_focuskeyword,
×
259
            --linebreak--, tx_yoastseo_focuskeyword_synonyms,
260
            --linebreak--, tx_yoastseo_focuskeyword_analysis'
×
261
        );
×
262

263
        ExtensionManagementUtility::addFieldsToPalette(
×
264
            $this->table,
×
265
            'yoast-relatedkeywords',
×
266
            '--linebreak--, tx_yoastseo_focuskeyword_related '
×
267
        );
×
268

269
        ExtensionManagementUtility::addFieldsToPalette(
×
270
            $this->table,
×
271
            'yoast-insights',
×
272
            '--linebreak--, tx_yoastseo_insights'
×
273
        );
×
274

275
        ExtensionManagementUtility::addFieldsToPalette(
×
276
            $this->table,
×
277
            'yoast-advanced-robots',
×
278
            '--linebreak--, tx_yoastseo_robots_noimageindex,tx_yoastseo_robots_noarchive,tx_yoastseo_robots_nosnippet'
×
279
        );
×
280

281
        ExtensionManagementUtility::addFieldsToPalette(
×
282
            $this->table,
×
283
            'yoast-advanced',
×
NEW
284
            '--linebreak--, tx_yoastseo_disable_analysis, tx_yoastseo_hide_snippet_preview'
×
285
        );
×
NEW
286
        $GLOBALS['TCA'][$this->table]['palettes']['yoast-advanced']['description']
×
NEW
287
            = self::LL_PREFIX_TCA . 'pages.palettes.advanced.description';
×
288
    }
289

290
    protected function addToTypes(): void
291
    {
292
        ExtensionManagementUtility::addToAllTCAtypes(
×
293
            $this->table,
×
294
            '--palette--;Label;yoast-snippetpreview,',
×
295
            $this->types,
×
296
            'before:seo_title'
×
297
        );
×
298

299
        ExtensionManagementUtility::addToAllTCAtypes(
×
300
            $this->table,
×
301
            '--palette--;' . self::LL_PREFIX_TCA . 'pages.palettes.readability;yoast-readability,
×
302
            --palette--;' . self::LL_PREFIX_TCA . 'pages.palettes.focusKeyphrase;yoast-focuskeyword,
×
303
            --palette--;' . self::LL_PREFIX_TCA . 'pages.palettes.focusRelatedKeyphrases;yoast-relatedkeywords,
×
304
            --palette--;' . self::LL_PREFIX_TCA . 'pages.palettes.insights;yoast-insights,',
×
305
            $this->types,
×
306
            'after: tx_yoastseo_cornerstone'
×
307
        );
×
308

309
        ExtensionManagementUtility::addToAllTCAtypes(
×
310
            $this->table,
×
311
            '--palette--;' . self::LL_PREFIX_TCA . 'pages.palettes.robots;yoast-advanced-robots,',
×
312
            $this->types,
×
313
            'after:no_follow'
×
314
        );
×
315

316
        ExtensionManagementUtility::addToAllTCAtypes(
×
317
            $this->table,
×
NEW
318
            '--palette--;' . self::LL_PREFIX_TCA . 'pages.palettes.advanced;yoast-advanced,',
×
319
            $this->types,
×
320
            'after: sitemap_priority'
×
321
        );
×
322
    }
323

324
    /**
325
     * @return array<array<int|string, string|bool>>
326
     */
327
    protected function getInvertedCheckbox(): array
328
    {
329
        return [
×
330
            [
×
331
                1 => '',
×
332
                'invertStateDisplay' => true,
×
NEW
333
                'label' => '',
×
334
            ],
×
335
        ];
×
336
    }
337
}
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