function ComponentValidator::getClassProps

Same name in this branch
  1. 11.x core/lib/Drupal/Core/Theme/Component/ComponentValidator.php \Drupal\Core\Theme\Component\ComponentValidator::getClassProps()
Same name in other branches
  1. 10 core/modules/sdc/src/Component/ComponentValidator.php \Drupal\sdc\Component\ComponentValidator::getClassProps()
  2. 10 core/lib/Drupal/Core/Theme/Component/ComponentValidator.php \Drupal\Core\Theme\Component\ComponentValidator::getClassProps()

Gets the props that are not JSON based.

Parameters

array $props_schema: The schema for the props.

Return value

array The class props.

2 calls to ComponentValidator::getClassProps()
ComponentValidator::validateClassProps in core/modules/sdc/src/Component/ComponentValidator.php
Validates the props that are not JSON Schema.
ComponentValidator::validateDefinition in core/modules/sdc/src/Component/ComponentValidator.php
Validates the component metadata file.

File

core/modules/sdc/src/Component/ComponentValidator.php, line 274

Class

ComponentValidator
Validates a component based on its definition and the component schema.

Namespace

Drupal\sdc\Component

Code

private function getClassProps(array $props_schema) : array {
    $classes_per_prop = [];
    foreach ($props_schema['properties'] ?? [] as $prop_name => $prop_def) {
        $type = $prop_def['type'] ?? 'null';
        $types = is_string($type) ? [
            $type,
        ] : $type;
        // For each possible type, check if it is a class.
        $class_types = array_filter($types, static fn(string $type) => !in_array($type, [
            'array',
            'boolean',
            'integer',
            'null',
            'number',
            'object',
            'string',
        ]));
        $classes_per_prop[$prop_name] = $class_types;
    }
    return array_filter($classes_per_prop);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.