• 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/Frontend/AdditionalPreviewData.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\Frontend;
13

14
use TYPO3\CMS\Core\SingletonInterface;
15
use TYPO3\CMS\Core\Site\Entity\Site;
16
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
17
use TYPO3\CMS\Core\Utility\GeneralUtility;
18
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
19
use YoastSeoForTypo3\YoastSeo\Service\Frontend\FrontendServiceInterface;
20
use YoastSeoForTypo3\YoastSeo\Service\YoastRequestService;
21

22
class AdditionalPreviewData implements SingletonInterface
23
{
24
    /** @var array<string, mixed> */
25
    protected array $config;
26

27
    public function __construct(
28
        protected YoastRequestService $yoastRequestService,
29
        protected FrontendServiceInterface $frontendService,
NEW
30
    ) {}
×
31

32
    /**
33
     * @param array<string, mixed> $params
34
     */
35
    public function render(array &$params, object $pObj): void
36
    {
37
        $serverParams = $GLOBALS['TYPO3_REQUEST'] ? $GLOBALS['TYPO3_REQUEST']->getServerParams() : $_SERVER;
×
38
        if (!$this->yoastRequestService->isValidRequest($serverParams)) {
×
39
            return;
×
40
        }
41

NEW
42
        $this->config = $this->frontendService->getTyposcriptConfiguration();
×
43

NEW
44
        $pageTitleConfiguration = $this->getPageTitlePrependAppend();
×
45
        setcookie('yoast-preview-tstamp', (string)time()); // To prevent caching in for example varnish
×
NEW
46
        $params['headerData']['YoastPreview'] = sprintf(
×
NEW
47
            '<meta name="x-yoast-title-config" value="%s|||%s" />',
×
NEW
48
            $pageTitleConfiguration['prepend'],
×
NEW
49
            $pageTitleConfiguration['append']
×
NEW
50
        );
×
51
    }
52

53
    protected function getWebsiteTitle(): string
54
    {
55
        $request = $GLOBALS['TYPO3_REQUEST'];
×
56
        $language = $request->getAttribute('language');
×
57
        if ($language instanceof SiteLanguage && !empty($language->getWebsiteTitle())) {
×
58
            return trim($language->getWebsiteTitle());
×
59
        }
60
        $site = $request->getAttribute('site');
×
61
        if ($site instanceof Site && !empty($site->getConfiguration()['websiteTitle'] ?? '')) {
×
62
            return trim($site->getConfiguration()['websiteTitle']);
×
63
        }
64

65
        if (!empty($GLOBALS['TSFE']->tmpl->setup['sitetitle'] ?? '')) {
×
66
            return trim($GLOBALS['TSFE']->tmpl->setup['sitetitle']);
×
67
        }
68

69
        return '';
×
70
    }
71

72
    /**
73
     * @return string[]
74
     */
75
    protected function getPageTitlePrependAppend(): array
76
    {
77
        $prependAppend = ['prepend' => '', 'append' => ''];
×
78
        $siteTitle = $this->getWebsiteTitle();
×
79
        $pageTitleFirst = (bool)($this->config['pageTitleFirst'] ?? false);
×
80
        $pageTitleSeparator = $this->getPageTitleSeparator();
×
81
        // only show a separator if there are both site title and page title
82
        if (empty($siteTitle)) {
×
83
            $pageTitleSeparator = '';
×
84
        } elseif (empty($pageTitleSeparator)) {
×
85
            // use the default separator if non given
86
            $pageTitleSeparator = ': ';
×
87
        }
88

89
        if ($pageTitleFirst) {
×
90
            $prependAppend['append'] = $pageTitleSeparator . $siteTitle;
×
91
        } else {
92
            $prependAppend['prepend'] = $siteTitle . $pageTitleSeparator;
×
93
        }
94

95
        return $prependAppend;
×
96
    }
97

98
    protected function getPageTitleSeparator(): string
99
    {
100
        if (!isset($this->config['pageTitleSeparator']) || $this->config['pageTitleSeparator'] === '') {
×
101
            return '';
×
102
        }
103

104
        if (is_array($this->config['pageTitleSeparator.'] ?? null)) {
×
105
            return (string)GeneralUtility::makeInstance(ContentObjectRenderer::class)
×
106
                ->stdWrap($this->config['pageTitleSeparator'], $this->config['pageTitleSeparator.']);
×
107
        }
108

109
        return $this->config['pageTitleSeparator'] . ' ';
×
110
    }
111
}
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