public static function TwigTweakExtension::withFilter in Twig Tweak 3.x
Same name and namespace in other branches
- 3.1.x src/TwigTweakExtension.php \Drupal\twig_tweak\TwigTweakExtension::withFilter()
Adds new element to the array.
Parameters
array $build: The renderable array to add the child item.
mixed $key: The key of the new element.
mixed $element: The element to add.
Return value
array The modified array.
File
- src/
TwigTweakExtension.php, line 573
Class
- TwigTweakExtension
- Twig extension with some useful functions and filters.
Namespace
Drupal\twig_tweakCode
public static function withFilter(array $build, $key, $element) : array {
if (is_array($key)) {
NestedArray::setValue($build, $key, $element);
}
else {
$build[$key] = $element;
}
return $build;
}