public static function Element::isEmpty

public static Element::isEmpty(array $elements)

Indicates whether the given element is empty.

An element that only has #cache set is considered empty, because it will render to the empty string.

Parameters

array $elements: The element.

Return value

bool Whether the given element is empty.

File

core/lib/Drupal/Core/Render/Element.php, line 198

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\Core\Render

Code

public static function isEmpty(array $elements) {
  return empty($elements) || (count($elements) === 1 && array_keys($elements) === ['#cache']);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Render!Element.php/function/Element::isEmpty/8.1.x