* ``` * * @internal */ final class WorkspaceTitleViewHelper extends AbstractViewHelper { public function __construct( #[Autowire(service: 'cache.runtime')] private readonly FrontendInterface $workspaceTitleRuntimeCache ) {} public function initializeArguments(): void { $this->registerArgument('uid', 'int', 'UID of the workspace', true); } /** * Return resolved workspace title or empty string if it can not be resolved. * * @throws \InvalidArgumentException */ public function render(): string { $uid = $this->arguments['uid']; $cacheIdentifier = 'belog-viewhelper-workspace-title_' . $uid; if ($this->workspaceTitleRuntimeCache->has($cacheIdentifier)) { return $this->workspaceTitleRuntimeCache->get($cacheIdentifier); } if ($uid === 0) { $this->workspaceTitleRuntimeCache->set($cacheIdentifier, htmlspecialchars(self::getLanguageService()->sL( 'LLL:EXT:belog/Resources/Private/Language/locallang.xlf:live' ))); } elseif (!ExtensionManagementUtility::isLoaded('workspaces')) { $this->workspaceTitleRuntimeCache->set($cacheIdentifier, ''); } else { $workspace = BackendUtility::getRecord('sys_workspace', $uid); $this->workspaceTitleRuntimeCache->set($cacheIdentifier, $workspace['title'] ?? ''); } return $this->workspaceTitleRuntimeCache->get($cacheIdentifier); } private static function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } }