‪TYPO3CMS  ‪main
WorkspaceTitleViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use TYPO3\CMS\Backend\Utility\BackendUtility;
23 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
25 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
26 
32 final class ‪WorkspaceTitleViewHelper extends AbstractViewHelper
33 {
34  use CompileWithRenderStatic;
35 
39  protected static array ‪$workspaceTitleRuntimeCache = [];
40 
41  public function ‪initializeArguments(): void
42  {
43  $this->registerArgument('uid', 'int', 'UID of the workspace', true);
44  }
45 
52  public static function ‪renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
53  {
54  ‪$uid = $arguments['uid'];
55  if (isset(self::$workspaceTitleRuntimeCache[‪$uid])) {
56  return self::$workspaceTitleRuntimeCache[‪$uid];
57  }
58  if (‪$uid === 0) {
59  self::$workspaceTitleRuntimeCache[‪$uid] = htmlspecialchars(self::getLanguageService()->sL(
60  'LLL:EXT:belog/Resources/Private/Language/locallang.xlf:live'
61  ));
62  } elseif (!‪ExtensionManagementUtility::isLoaded('workspaces')) {
63  self::$workspaceTitleRuntimeCache[‪$uid] = '';
64  } else {
65  $workspace = BackendUtility::getRecord('sys_workspace', ‪$uid);
66  self::$workspaceTitleRuntimeCache[‪$uid] = $workspace['title'] ?? '';
67  }
68  return self::$workspaceTitleRuntimeCache[‪$uid];
69  }
70 
71  protected static function ‪getLanguageService(): ‪LanguageService
72  {
73  return ‪$GLOBALS['LANG'];
74  }
75 }
‪TYPO3\CMS\Belog\ViewHelpers
‪TYPO3\CMS\Belog\ViewHelpers\WorkspaceTitleViewHelper\$workspaceTitleRuntimeCache
‪static array $workspaceTitleRuntimeCache
Definition: WorkspaceTitleViewHelper.php:38
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\isLoaded
‪static isLoaded(string $key)
Definition: ExtensionManagementUtility.php:55
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility
Definition: ExtensionManagementUtility.php:32
‪TYPO3\CMS\Belog\ViewHelpers\WorkspaceTitleViewHelper\getLanguageService
‪static getLanguageService()
Definition: WorkspaceTitleViewHelper.php:70
‪TYPO3\CMS\Belog\ViewHelpers\WorkspaceTitleViewHelper\initializeArguments
‪initializeArguments()
Definition: WorkspaceTitleViewHelper.php:40
‪TYPO3\CMS\Belog\ViewHelpers\WorkspaceTitleViewHelper\renderStatic
‪static renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
Definition: WorkspaceTitleViewHelper.php:51
‪TYPO3\CMS\Belog\ViewHelpers\WorkspaceTitleViewHelper
Definition: WorkspaceTitleViewHelper.php:33
‪TYPO3\CMS\Webhooks\Message\$uid
‪identifier readonly int $uid
Definition: PageModificationMessage.php:35
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:46