TYPO3 CMS  TYPO3_7-6
WorkspaceTitleViewHelper.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 
26 {
32  protected static $workspaceTitleRuntimeCache = [];
33 
40  public function render($uid)
41  {
42  return static::renderStatic(
43  [
44  'uid' => $uid
45  ],
47  $this->renderingContext
48  );
49  }
50 
59  {
60  $uid = $arguments['uid'];
61 
62  if (isset(static::$workspaceTitleRuntimeCache[$uid])) {
63  return htmlspecialchars(static::$workspaceTitleRuntimeCache[$uid]);
64  }
65 
66  if ($uid === 0) {
67  static::$workspaceTitleRuntimeCache[$uid] = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('live', $renderingContext->getControllerContext()->getRequest()->getControllerExtensionName());
68  } elseif (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces')) {
69  static::$workspaceTitleRuntimeCache[$uid] = '';
70  } else {
71  $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
72  $workspaceRepository = $objectManager->get(\TYPO3\CMS\Belog\Domain\Repository\WorkspaceRepository::class);
74  $workspace = $workspaceRepository->findByUid($uid);
75  // $workspace may be null, force empty string in this case
76  static::$workspaceTitleRuntimeCache[$uid] = ($workspace === null) ? '' : $workspace->getTitle();
77  }
78 
79  return htmlspecialchars(static::$workspaceTitleRuntimeCache[$uid]);
80  }
81 }
static translate($key, $extensionName, $arguments=null)
$uid
Definition: server.php:38
static renderStatic(array $arguments, \Closure $renderChildrenClosure, \TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface $renderingContext)