18 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
19 use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
20 use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
28 use CompileWithRenderStatic;
35 $this->registerArgument(
'array',
'array',
'Array to search in',
true);
36 $this->registerArgument(
'key',
'string',
'Key to return its value',
true);
37 $this->registerArgument(
'subKey',
'string',
'If result of key access is an array, subkey can be used to fetch an element from this again',
false,
'');
49 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
51 $array = $arguments[
'array'];
52 $key = $arguments[
'key'];
53 $subKey = $arguments[
'subKey'];
55 if (is_array($array) && isset($array[$key])) {
56 $result = $array[$key];
57 if (is_array($result) && $subKey && isset($result[$subKey])) {
58 $result = $result[$subKey];
61 if (!is_scalar($result)) {
62 throw new Exception(
'Only scalar return values (string, int, float or double) are supported.', 1382284105);