Skip to content

Commit

Permalink
[TASK] Moved hideYoastInPageModule check within VisibilityChecker to …
Browse files Browse the repository at this point in the history
…separate method
  • Loading branch information
RinyVT committed Dec 18, 2024
1 parent 9607e4b commit 5e4eeb2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Classes/Service/PageLayoutHeader/VisibilityChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace YoastSeoForTypo3\YoastSeo\Service\PageLayoutHeader;

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use YoastSeoForTypo3\YoastSeo\Traits\BackendUserTrait;
use YoastSeoForTypo3\YoastSeo\Utility\YoastUtility;

Expand All @@ -31,25 +32,31 @@ public function shouldShowPreview(int $pageId, array $pageRecord): bool
protected function isSnippetPreviewEnabled(int $pageId, array $pageRecord): bool
{
$backendUser = $this->getBackendUser();

if (!$backendUser->check('non_exclude_fields', 'pages:tx_yoastseo_snippetpreview')) {
return false;
}

if ((bool)($backendUser->uc['hideYoastInPageModule'] ?? false)) {
if ($this->hideFromUserSettings($backendUser)) {
return false;
}

$pageTsConfig = $this->getPageTsConfig($pageId);
if (isset($pageTsConfig['mod.']['web_SeoPlugin.']['disableSnippetPreview'])
&& (int)$pageTsConfig['mod.']['web_SeoPlugin.']['disableSnippetPreview'] === 1
) {
if ((int)($pageTsConfig['mod.']['web_SeoPlugin.']['disableSnippetPreview'] ?? 0) === 1) {
return false;
}

return !((bool)($pageRecord['tx_yoastseo_hide_snippet_preview'] ?? false));
}

protected function hideFromUserSettings(BackendUserAuthentication $backendUser): bool
{
if (isset($backendUser->uc['hideYoastInPageModule'])) {
return (bool)$backendUser->uc['hideYoastInPageModule'];
}

return false;
}

/**
* @return array<string, mixed>
*/
Expand Down

0 comments on commit 5e4eeb2

Please sign in to comment.