57 lines
1.6 KiB
PHP
Executable File
57 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace Evoweb\EwBase\ViewHelpers\Iterator;
|
|
|
|
/*
|
|
* This file is developed by evoWeb.
|
|
*
|
|
* It is free software; you can redistribute it and/or modify it under
|
|
* the terms of the GNU General Public License, either version 2
|
|
* of the License, or any later version.
|
|
*
|
|
* For the full copyright and license information, please read the
|
|
* LICENSE.txt file that was distributed with this source code.
|
|
*/
|
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
|
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
|
|
|
class AddViewHelper extends AbstractViewHelper
|
|
{
|
|
use CompileWithRenderStatic;
|
|
|
|
/**
|
|
* @var bool
|
|
*/
|
|
protected $escapeOutput = false;
|
|
|
|
public function initializeArguments()
|
|
{
|
|
parent::initializeArguments();
|
|
$this->registerArgument('array', 'array', 'Array to add value to');
|
|
$this->registerArgument('key', 'string', 'Key to add value by', true);
|
|
$this->registerArgument('value', 'mixed', 'Value to add');
|
|
}
|
|
|
|
/**
|
|
* @param array $arguments
|
|
* @param \Closure $renderChildrenClosure
|
|
* @param RenderingContextInterface $renderingContext
|
|
*
|
|
* @return array
|
|
*/
|
|
public static function renderStatic(
|
|
array $arguments,
|
|
\Closure $renderChildrenClosure,
|
|
RenderingContextInterface $renderingContext
|
|
) {
|
|
$array = $arguments['array'] ?: [];
|
|
$key = $arguments['key'];
|
|
$value = $arguments['value'] ?: $renderChildrenClosure();
|
|
|
|
return array_merge($array, [$key => $value]);
|
|
}
|
|
}
|