DigiComp.FluidRenderFunctions/Classes/ViewHelpers/Traits/ValidateRenderFunctionTrait.php

27 lines
885 B
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace DigiComp\FluidRenderFunctions\ViewHelpers\Traits;
use DigiComp\FluidRenderFunctions\InvokeRenderFunctionInterface;
use DigiComp\FluidRenderFunctions\ViewHelpers\RegisterRenderFunctionViewHelper;
trait ValidateRenderFunctionTrait
{
public function validateRenderFunctionArgument(string $argumentName)
{
$renderFunction = $this->viewHelperVariableContainer->get(
RegisterRenderFunctionViewHelper::class,
$this->arguments[$argumentName]
);
if (!($renderFunction instanceof InvokeRenderFunctionInterface)) {
throw new \InvalidArgumentException(
'render function with name "' . $this->arguments[$argumentName] . '" has not been registered.',
1717293038
);
}
$this->arguments[$argumentName] = $renderFunction;
}
}