[TASK] Move BE User initialization into PSR-15 middleware
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / ViewHelpers / TimeSinceLastUpdateViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Extensionmanager\ViewHelpers;
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
17 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
18 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
20
21 /**
22 * Shows the elapsed time since the last update of the extension repository
23 * from TER in a readable manner.
24 *
25 * @internal
26 */
27 class TimeSinceLastUpdateViewHelper extends AbstractViewHelper
28 {
29 use CompileWithRenderStatic;
30
31 /**
32 * Initialize arguments
33 */
34 public function initializeArguments()
35 {
36 $this->registerArgument('lastUpdateTime', \DateTime::class, 'The date of the last update.', true);
37 }
38
39 /**
40 * Render method
41 *
42 * @param array $arguments
43 * @param \Closure $renderChildrenClosure
44 * @param RenderingContextInterface $renderingContext
45 *
46 * @return string
47 */
48 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
49 {
50 $lastUpdateTime = $arguments['lastUpdateTime'];
51 if (null === $lastUpdateTime) {
52 return $GLOBALS['LANG']->sL(
53 'LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.never'
54 );
55 }
56 return \TYPO3\CMS\Backend\Utility\BackendUtility::calcAge(
57 time() - $lastUpdateTime->format('U'),
58 $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears')
59 );
60 }
61 }