moduleTemplateFactory->create($request); $this->registerDocHeaderButtons($view, $request->getAttribute('module')); $view->assignMultiple([ 'configurationStatus' => $this->getConfigurationStatus(), 'scopes' => array_map(strval(...), $this->scopeRepository->findAll()), 'controlUri' => $this->uriBuilder->buildUriFromRoutePath('/ajax/security/csp/control'), 'extLowlevelAvailable' => ExtensionManagementUtility::isLoaded('lowlevel'), ]); return $view->renderResponse('Security/CspModule'); } protected function registerDocHeaderButtons(ModuleTemplate $view, ModuleInterface $currentModule): void { $view->getDocHeaderComponent()->setShortcutContext( $currentModule->getIdentifier(), $this->getLanguageService()->translate('title', 'backend.modules.content_security_policy') ); $view->getDocHeaderComponent()->disableAutomaticReloadButton(); $reloadButton = $this->componentFactory ->createReloadButton((string)$this->uriBuilder->buildUriFromRoute($currentModule->getIdentifier())) ->setDataAttributes(['csp-reports-handler' => 'refresh']); $view->addButtonToButtonBar($reloadButton, ButtonBar::BUTTON_POSITION_RIGHT); } protected function getConfigurationStatus(): array { return [ 'featureDisabled' => array_filter([ 'backend' => [], 'frontend' => !$this->features->isFeatureEnabled('security.frontend.enforceContentSecurityPolicy') && !$this->features->isFeatureEnabled('security.frontend.reportContentSecurityPolicy') ? ['enforce', 'report'] : [], ]), 'customReporting' => array_filter([ 'BE' => $GLOBALS['TYPO3_CONF_VARS']['BE']['contentSecurityPolicyReportingUrl'] ?? '', 'FE' => $GLOBALS['TYPO3_CONF_VARS']['FE']['contentSecurityPolicyReportingUrl'] ?? '', ]), ]; } protected function getBackendUser(): BackendUserAuthentication { return $GLOBALS['BE_USER']; } protected function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } }