• 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

52.94
/Classes/Service/PageLayoutHeader/VisibilityChecker.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace YoastSeoForTypo3\YoastSeo\Service\PageLayoutHeader;
6

7
use TYPO3\CMS\Backend\Utility\BackendUtility;
8
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
9
use YoastSeoForTypo3\YoastSeo\Traits\BackendUserTrait;
10
use YoastSeoForTypo3\YoastSeo\Utility\YoastUtility;
11

12
class VisibilityChecker
13
{
14
    use BackendUserTrait;
15

16
    /**
17
     * @param array<string, string> $pageRecord
18
     */
19
    public function shouldShowPreview(int $pageId, array $pageRecord): bool
20
    {
NEW
21
        if (!$this->isSnippetPreviewEnabled($pageId, $pageRecord)) {
×
NEW
22
            return false;
×
23
        }
24

NEW
25
        $allowedDoktypes = YoastUtility::getAllowedDoktypes();
×
NEW
26
        return isset($pageRecord['doktype']) && in_array((int)$pageRecord['doktype'], $allowedDoktypes, true);
×
27
    }
28

29
    /**
30
     * @param array<string, string> $pageRecord
31
     */
32
    protected function isSnippetPreviewEnabled(int $pageId, array $pageRecord): bool
33
    {
34
        $backendUser = $this->getBackendUser();
8✔
35
        if (!$backendUser->check('non_exclude_fields', 'pages:tx_yoastseo_snippetpreview')) {
8✔
NEW
36
            return false;
×
37
        }
38

39
        if ($this->hideFromUserSettings($backendUser)) {
8✔
NEW
40
            return false;
×
41
        }
42

43
        $pageTsConfig = $this->getPageTsConfig($pageId);
8✔
44
        if ((int)($pageTsConfig['mod.']['web_SeoPlugin.']['disableSnippetPreview'] ?? 0) === 1) {
8✔
45
            return false;
1✔
46
        }
47

48
        return !((bool)($pageRecord['tx_yoastseo_hide_snippet_preview'] ?? false));
7✔
49
    }
50

51
    protected function hideFromUserSettings(BackendUserAuthentication $backendUser): bool
52
    {
53
        if (isset($backendUser->uc['hideYoastInPageModule'])) {
8✔
NEW
54
            return (bool)$backendUser->uc['hideYoastInPageModule'];
×
55
        }
56

57
        return false;
8✔
58
    }
59

60
    /**
61
     * @return array<string, mixed>
62
     */
63
    protected function getPageTsConfig(int $pageId): array
64
    {
NEW
65
        return BackendUtility::getPagesTSconfig($pageId);
×
66
    }
67
}
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