TYPO3 CMS  TYPO3_8-7
HistoryEntryViewHelper.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 
29 
35 {
37 
43  protected $escapeOutput = false;
44 
48  public function initializeArguments()
49  {
50  parent::initializeArguments();
51  $this->registerArgument('uid', 'int', 'Uid of the log entry', true);
52  }
53 
64  public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
65  {
66  if (!$renderingContext instanceof RenderingContext) {
67  throw new \InvalidArgumentException('The given rendering context is not of type "TYPO3\CMS\Fluid\Core\Rendering\RenderingContext"', 1468363945);
68  }
70  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
72  $historyEntryRepository = $objectManager->get(HistoryEntryRepository::class);
74  $historyEntry = $historyEntryRepository->findOneBySysLogUid($arguments['uid']);
75  $controllerContext = $renderingContext->getControllerContext();
77  $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
78 
79  if (!$historyEntry instanceof HistoryEntry) {
80  return '';
81  }
82  $historyLabel = LocalizationUtility::translate(
83  'changesInFields',
84  $controllerContext->getRequest()->getControllerExtensionName(),
85  [$historyEntry->getFieldlist()]
86  );
87  $titleLable = LocalizationUtility::translate(
88  'showHistory',
89  $controllerContext->getRequest()->getControllerExtensionName()
90  );
91  $historyIcon = $iconFactory->getIcon('actions-document-history-open', Icon::SIZE_SMALL)->render();
92  $historyHref = BackendUtility::getModuleUrl(
93  'record_history',
94  [
95  'sh_uid' => $historyEntry->getUid(),
96  'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI'),
97  ]
98  );
99  $historyLink = '<a href="' . htmlspecialchars($historyHref) . '" title="' . htmlspecialchars($titleLable) . '">' . $historyIcon . '</a>';
100  return htmlspecialchars($historyLabel) . '&nbsp;' . $historyLink;
101  }
102 }
static translate($key, $extensionName=null, $arguments=null)
initializeArguments()
static makeInstance($className,... $constructorArguments)
$escapeOutput