• 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/Form/Element/AbstractSocialPreview.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\Form\Element;
13

14
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
15
use TYPO3\CMS\Backend\Form\AbstractNode;
16
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
17
use TYPO3\CMS\Core\Resource\FileReference;
18
use TYPO3\CMS\Core\Resource\FileRepository;
19
use TYPO3\CMS\Core\Site\Entity\Site;
20
use YoastSeoForTypo3\YoastSeo\Service\Form\NodeTemplateService;
21

22
#[Autoconfigure(public: true)]
23
abstract class AbstractSocialPreview extends AbstractNode
24
{
25
    public function __construct(
26
        protected NodeTemplateService $templateService,
27
        protected FileRepository $fileRepository,
NEW
28
    ) {}
×
29

30
    /**
31
     * @param array<string, mixed> $data
32
     */
33
    public function setData(array $data): void
34
    {
NEW
35
        $this->data = $data;
×
36
    }
37

38
    /**
39
     * @return array<string, mixed>
40
     */
41
    public function render(): array
42
    {
NEW
43
        $resultArray = $this->initializeResultArray();
×
44

NEW
45
        $resultArray['javaScriptModules'][] = JavaScriptModuleInstruction::create(
×
NEW
46
            '@yoast/yoast-seo-for-typo3/' . $this->getSocialType() . '-preview.js'
×
NEW
47
        )->invoke('initialize', ['fieldSelectors' => $this->formatFieldSelectors()]);
×
48

NEW
49
        $resultArray['html'] = $this->templateService->renderView(ucfirst($this->getSocialType()) . 'Preview', [
×
NEW
50
            'data' => $this->data,
×
NEW
51
            'socialType' => $this->getSocialType(),
×
NEW
52
            'siteBase' => $this->getSiteBase(),
×
NEW
53
            'image' => $this->getImage(),
×
NEW
54
        ]);
×
NEW
55
        return $resultArray;
×
56
    }
57

58
    /**
59
     * @return array<string, string>
60
     */
61
    protected function formatFieldSelectors(): array
62
    {
NEW
63
        $fieldSelectors = $this->getFieldSelectors();
×
NEW
64
        array_walk($fieldSelectors, function (&$value, $key) {
×
NEW
65
            if (str_contains($key, 'ImageContainer')) {
×
NEW
66
                return;
×
67
            }
NEW
68
            $value = 'data' . str_replace($this->data['fieldName'], $value, $this->data['elementBaseName']);
×
NEW
69
        });
×
NEW
70
        return $fieldSelectors;
×
71
    }
72

73
    protected function getSiteBase(): string
74
    {
NEW
75
        $languageId = 0;
×
NEW
76
        $languageField = $GLOBALS['TCA'][$this->data['tableName']]['ctrl']['languageField'] ?? '';
×
NEW
77
        if (isset($this->data['databaseRow'][$languageField]) && !empty($this->data['databaseRow'][$languageField])) {
×
NEW
78
            $languageId = (int)$this->data['databaseRow'][$languageField] > -1
×
NEW
79
                ? (int)$this->data['databaseRow'][$languageField]
×
NEW
80
                : 0;
×
81
        }
82

83
        /** @var Site $site */
NEW
84
        $site = $this->data['site'];
×
NEW
85
        $host = $site->getLanguageById($languageId)->getBase()->getHost();
×
NEW
86
        if (!empty($host)) {
×
NEW
87
            return $host;
×
88
        }
89

90
        // Fall back to request host
NEW
91
        return $this->data['request']->getUri()->getHost();
×
92
    }
93

94
    protected function getImage(): ?FileReference
95
    {
NEW
96
        $fileReferences = $this->fileRepository->findByRelation($this->data['tableName'], $this->getImageField(), $this->data['vanillaUid']);
×
NEW
97
        if (isset($fileReferences[0]) && $fileReferences[0] instanceof FileReference) {
×
NEW
98
            return $fileReferences[0];
×
99
        }
NEW
100
        return null;
×
101
    }
102

103
    protected function getImageContainerSelector(string $imageField): string
104
    {
NEW
105
        return 'data-' . $this->data['effectivePid'] . '-' . $this->data['tableName'] . '-' . $this->data['vanillaUid'] . '-' . $imageField;
×
106
    }
107

108
    abstract protected function getSocialType(): string;
109

110
    /**
111
     * @return array<string, string>
112
     */
113
    abstract protected function getFieldSelectors(): array;
114
    abstract protected function getImageField(): string;
115
}
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