function ResourceObjectNormalizer::processConfigEntitySchema
1 call to ResourceObjectNormalizer::processConfigEntitySchema()
- ResourceObjectNormalizer::getNormalizationSchema in core/
modules/ jsonapi/ src/ Normalizer/ ResourceObjectNormalizer.php - Retrieve JSON Schema for the normalization.
File
-
core/
modules/ jsonapi/ src/ Normalizer/ ResourceObjectNormalizer.php, line 306
Class
- ResourceObjectNormalizer
- Converts the JSON:API module ResourceObject into a JSON:API array structure.
Namespace
Drupal\jsonapi\NormalizerCode
protected function processConfigEntitySchema(ResourceType $resource_type, array $context, array &$attributes_schema) : void {
// This is largely the same as in ResourceObject but without a real entity.
$fields = $resource_type->getFields();
// Filter the array based on the field names.
$enabled_field_names = array_filter(array_keys($fields), static fn(string $internal_field_name) => $resource_type->isFieldEnabled($internal_field_name));
// Return a sub-array of $output containing the keys in $enabled_fields.
$input = array_intersect_key($fields, array_flip($enabled_field_names));
foreach ($input as $field_name => $field_value) {
$attributes_schema['properties'][$resource_type->getPublicName($field_name)] = [
'title' => $field_name,
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.