function ComponentValidator::nullifyClassPropsSchema
Same name in this branch
- 11.x core/modules/sdc/src/Component/ComponentValidator.php \Drupal\sdc\Component\ComponentValidator::nullifyClassPropsSchema()
Same name in other branches
- 10 core/modules/sdc/src/Component/ComponentValidator.php \Drupal\sdc\Component\ComponentValidator::nullifyClassPropsSchema()
- 10 core/lib/Drupal/Core/Theme/Component/ComponentValidator.php \Drupal\Core\Theme\Component\ComponentValidator::nullifyClassPropsSchema()
Utility method to ensure the schema for class props is set to 'null'.
Parameters
array $schema_props: The schema for all the props.
array $classes_per_prop: Associative array that associates prop names with their prop classes.
Return value
array The new schema.
2 calls to ComponentValidator::nullifyClassPropsSchema()
- ComponentValidator::validateClassProps in core/
lib/ Drupal/ Core/ Theme/ Component/ ComponentValidator.php - Validates the props that are not JSON Schema.
- ComponentValidator::validateDefinition in core/
lib/ Drupal/ Core/ Theme/ Component/ ComponentValidator.php - Validates the component metadata file.
File
-
core/
lib/ Drupal/ Core/ Theme/ Component/ ComponentValidator.php, line 298
Class
- ComponentValidator
- Validates a component based on its definition and the component schema.
Namespace
Drupal\Core\Theme\ComponentCode
private function nullifyClassPropsSchema(array $schema_props, array $classes_per_prop) : array {
foreach ($schema_props['properties'] as $prop_name => $prop_def) {
$class_types = $classes_per_prop[$prop_name] ?? [];
// Remove the non JSON Schema types for later JSON Schema validation.
$types = (array) ($prop_def['type'] ?? [
'null',
]);
$types = array_diff($types, $class_types);
$types = empty($types) ? [
'null',
] : $types;
$schema_props['properties'][$prop_name]['type'] = $types;
}
return $schema_props;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.