• 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/Form/Element/SnippetPreview.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace YoastSeoForTypo3\YoastSeo\Form\Element;
6

7
use TYPO3\CMS\Backend\Form\AbstractNode;
8
use TYPO3\CMS\Core\Utility\GeneralUtility;
9
use YoastSeoForTypo3\YoastSeo\Service\Form\NodeTemplateService;
10
use YoastSeoForTypo3\YoastSeo\Service\LocaleService;
11
use YoastSeoForTypo3\YoastSeo\Service\SnippetPreview\SnippetPreviewConfigurationBuilder;
12
use YoastSeoForTypo3\YoastSeo\Service\SnippetPreview\SnippetPreviewUrlGenerator;
13
use YoastSeoForTypo3\YoastSeo\Service\SnippetPreviewService;
14
use YoastSeoForTypo3\YoastSeo\Utility\YoastUtility;
15

16
class SnippetPreview extends AbstractNode
17
{
18
    // TODO: Use constructor DI when TYPO3 v11 can be dropped
19
    protected NodeTemplateService $templateService;
20
    protected SnippetPreviewConfigurationBuilder $configurationBuilder;
21
    protected SnippetPreviewUrlGenerator $urlGenerator;
22
    protected SnippetPreviewService $snippetPreviewService;
23

24
    protected string $previewUrl = '';
25
    protected int $languageId = 0;
26

27
    /**
28
     * @return array<string, mixed>
29
     */
30
    public function render(): array
31
    {
32
        if ($this->data['command'] === 'new') {
×
33
            return [];
×
34
        }
35

36
        $this->initialize();
×
37

38
        $resultArray = $this->initializeResultArray();
×
39
        $resultArray['stylesheetFiles'][] = 'EXT:yoast_seo/Resources/Public/CSS/yoast.min.css';
×
40

41
        if ($this->data['tableName'] === 'pages'
×
42
            && !in_array((int)($this->data['databaseRow']['doktype'][0] ?? 0), YoastUtility::getAllowedDoktypes(), true)) {
×
NEW
43
            $resultArray['html'] = $this->templateService->renderView('SnippetPreview', ['wrongDoktype' => true]);
×
44
            return $resultArray;
×
45
        }
46

NEW
47
        $snippetPreviewConfiguration = $this->configurationBuilder->buildConfigurationForTCA($this->data, $this->languageId);
×
48

NEW
49
        $this->snippetPreviewService->buildSnippetPreview($this->previewUrl, $this->data['databaseRow'], $snippetPreviewConfiguration);
×
50

NEW
51
        $resultArray['html'] = $this->templateService->renderView('SnippetPreview', [
×
52
            'previewUrl' => $this->previewUrl,
×
53
            'previewTargetId' => $this->data['fieldName'],
×
NEW
54
            'titleFieldSelector' => $snippetPreviewConfiguration['fieldSelectors']['title'],
×
NEW
55
            'descriptionFieldSelector' => $snippetPreviewConfiguration['fieldSelectors']['description'],
×
56
            'databaseRow' => $this->data['databaseRow'],
×
NEW
57
            'focusKeyword' => YoastUtility::getFocusKeywordOfRecord(
×
NEW
58
                (int)$this->data['databaseRow']['uid'],
×
NEW
59
                $this->data['tableName']
×
NEW
60
            ),
×
61
            'vanillaUid' => $this->data['vanillaUid'],
×
62
            'tableName' => $this->data['tableName'],
×
63
            'languageId' => $this->languageId,
×
64
        ]);
×
65

66
        return $resultArray;
×
67
    }
68

69
    protected function initialize(): void
70
    {
NEW
71
        $this->templateService = GeneralUtility::makeInstance(NodeTemplateService::class);
×
NEW
72
        $this->configurationBuilder = GeneralUtility::makeInstance(SnippetPreviewConfigurationBuilder::class);
×
NEW
73
        $this->urlGenerator = GeneralUtility::makeInstance(SnippetPreviewUrlGenerator::class);
×
NEW
74
        $this->snippetPreviewService = GeneralUtility::makeInstance(SnippetPreviewService::class);
×
75

NEW
76
        $this->previewUrl = $this->urlGenerator->getPreviewUrl($this->data);
×
NEW
77
        $this->languageId = GeneralUtility::makeInstance(LocaleService::class)->getLanguageIdFromData($this->data);
×
78
    }
79
}
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