1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace TYPO3\CMS\Adminpanel\ViewHelpers; |
5
|
|
|
|
6
|
|
|
/* |
7
|
|
|
* This file is part of the TYPO3 CMS project. |
8
|
|
|
* |
9
|
|
|
* It is free software; you can redistribute it and/or modify it under |
10
|
|
|
* the terms of the GNU General Public License, either version 2 |
11
|
|
|
* of the License, or any later version. |
12
|
|
|
* |
13
|
|
|
* For the full copyright and license information, please read the |
14
|
|
|
* LICENSE.txt file that was distributed with this source code. |
15
|
|
|
* |
16
|
|
|
* The TYPO3 project - inspiring people to share! |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use TYPO3\CMS\Adminpanel\ModuleApi\ContentProviderInterface; |
20
|
|
|
use TYPO3\CMS\Adminpanel\ModuleApi\ModuleData; |
21
|
|
|
use TYPO3\CMS\Adminpanel\ModuleApi\ModuleDataStorageCollection; |
22
|
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; |
23
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; |
24
|
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Render submodule content |
28
|
|
|
* |
29
|
|
|
* @internal |
30
|
|
|
*/ |
31
|
|
|
class SubModuleRenderViewHelper extends AbstractViewHelper |
32
|
|
|
{ |
33
|
|
|
use CompileWithRenderStatic; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* First level cache of user names |
37
|
|
|
* |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
protected static $usernameRuntimeCache = []; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Initializes the arguments |
44
|
|
|
*/ |
45
|
|
|
public function initializeArguments(): void |
46
|
|
|
{ |
47
|
|
|
$this->registerArgument( |
48
|
|
|
'module', |
49
|
|
|
ContentProviderInterface::class, |
50
|
|
|
'SubModule instance to be rendered', |
51
|
|
|
true |
52
|
|
|
); |
53
|
|
|
$this->registerArgument('data', ModuleDataStorageCollection::class, 'Data to be used for rendering', true); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Resolve user name from backend user id. |
58
|
|
|
* |
59
|
|
|
* @param array $arguments |
60
|
|
|
* @param \Closure $renderChildrenClosure |
61
|
|
|
* @param RenderingContextInterface $renderingContext |
62
|
|
|
* @return string Username or an empty string if there is no user with that UID |
63
|
|
|
*/ |
64
|
|
|
public static function renderStatic( |
65
|
|
|
array $arguments, |
66
|
|
|
\Closure $renderChildrenClosure, |
67
|
|
|
RenderingContextInterface $renderingContext |
68
|
|
|
): string { |
69
|
|
|
$module = $arguments['module']; |
70
|
|
|
/** @var \TYPO3\CMS\Adminpanel\ModuleApi\ModuleDataStorageCollection $data */ |
71
|
|
|
$data = $arguments['data']; |
72
|
|
|
$moduleData = $data->contains($module) ? $data->offsetGet($module) : new ModuleData(); |
73
|
|
|
return $module->getContent($moduleData); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|