Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Element.php

function Element::isRenderArray

Checks if a candidate is a render array.

Parameters

mixed $candidate: The candidate.

Return value

bool TRUE if it's a render array. FALSE otherwise.

2 calls to Element::isRenderArray()
ComponentElement::generateComponentTemplate in core/lib/Drupal/Core/Render/Element/ComponentElement.php
Generates the template to render the component.
ComponentValidator::validateProps in core/lib/Drupal/Core/Theme/Component/ComponentValidator.php
Validates that the props provided to the component.

File

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

Class

Element
Provides helper methods for Drupal render elements.

Namespace

Drupal\Core\Render

Code

public static function isRenderArray($candidate) : bool {
    if (!is_array($candidate)) {
        return FALSE;
    }
    if (empty($candidate)) {
        return FALSE;
    }
    foreach ($candidate as $key => $value) {
        if (!is_int($key) && $key !== '' && $key[0] === '#') {
            continue;
        }
        if (!is_array($value)) {
            return FALSE;
        }
        if (!static::isRenderArray($value)) {
            return FALSE;
        }
    }
    return TRUE;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal