You are here

public static function TwigTweakExtension::childrenFilter in Twig Tweak 3.1.x

Same name and namespace in other branches
  1. 3.x src/TwigTweakExtension.php \Drupal\twig_tweak\TwigTweakExtension::childrenFilter()

Filters out the children of a render array, optionally sorted by weight.

Parameters

array $build: The render array whose children are to be filtered.

bool $sort: Boolean to indicate whether the children should be sorted by weight.

Return value

array The element's children.

File

src/TwigTweakExtension.php, line 594

Class

TwigTweakExtension
Twig extension with some useful functions and filters.

Namespace

Drupal\twig_tweak

Code

public static function childrenFilter(array $build, bool $sort = FALSE) : array {
  $keys = Element::children($build, $sort);
  return array_intersect_key($build, array_flip($keys));
}