iconFactory = GeneralUtility::makeInstance(IconFactory::class); } public function getContext(): PageLayoutContext { return $this->context; } public function getGrid(): Grid { return $this->grid; } public function getPageIcon(): string { $localizedPageRecord = $this->context->getLocalizedPageRecord() ?? $this->context->getPageRecord(); return BackendUtility::wrapClickMenuOnIcon( $this->iconFactory->getIconForRecord('pages', $localizedPageRecord, IconSize::SMALL)->render(), 'pages', $localizedPageRecord['uid'] ); } public function getAllowTranslate(): bool { return $this->context->getDrawingConfiguration()->translateModeForTranslationsAllowed() && !($this->getTranslationData()['hasStandAloneContent'] ?? false); } public function getTranslationData(): array { return $this->translationInfo; } public function getAllowTranslateCopy(): bool { return $this->context->getDrawingConfiguration()->copyModeForTranslationsAllowed() && !($this->getTranslationData()['hasTranslations'] ?? false); } public function getAllowEditPage(): bool { return $this->getBackendUser()->doesUserHaveAccess($this->context->getPageRecord(), Permission::PAGE_EDIT) && $this->getBackendUser()->check('tables_modify', 'pages') && $this->getBackendUser()->checkLanguageAccess($this->context->getSiteLanguage()); } public function getPageRecordUid(): int { return $this->context->getLocalizedPageRecord()['uid'] ?? $this->context->getPageRecord()['uid']; } public function getPageRecord(): array { return $this->context->getLocalizedPageRecord() ?: $this->context->getPageRecord(); } public function getPageEditUrl(): string { return (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit_contextual', $this->getPageEditUrlParameters()); } public function getFullPageEditUrl(): string { return (string)GeneralUtility::makeInstance(UriBuilder::class)->buildUriFromRoute('record_edit', $this->getPageEditUrlParameters()); } private function getPageEditUrlParameters(): array { $pageRecordUid = $this->getPageRecordUid(); $urlParameters = [ 'edit' => [ 'pages' => [ $pageRecordUid => 'edit', ], ], 'module' => 'web_layout', 'returnUrl' => $this->context->getReturnUrl(), ]; // Disallow manual adjustment of the language field for pages if (($languageField = GeneralUtility::makeInstance(TcaSchemaFactory::class)->get('pages')->getCapability(TcaSchemaCapability::Language)->getLanguageField()->getName()) !== '') { $urlParameters['overrideVals']['pages'][$languageField] = $this->context->getSiteLanguage()->getLanguageId(); } return $urlParameters; } public function getAllowViewPage(): bool { return PreviewUriBuilder::create($this->context->getLocalizedPageRecord() ?? $this->context->getPageRecord())->isPreviewable(); } public function getPreviewUrlAttributes(): string { $pageId = $this->context->getPageId(); $languageId = $this->context->getSiteLanguage()->getLanguageId(); return (string)PreviewUriBuilder::create($this->context->getLocalizedPageRecord() ?? $this->context->getPageRecord()) ->withRootLine(BackendUtility::BEgetRootLine($pageId)) ->withLanguage($languageId) ->serializeDispatcherAttributes(); } protected function getBackendUser(): BackendUserAuthentication { return $GLOBALS['BE_USER']; } }