public function JsonapiResourceConfig::getFieldMapping in JSON:API Extras 8.3
Returns a field mapping as expected by JSON:API 2.x' ResourceType class.
See also
\Drupal\jsonapi\ResourceType\ResourceType::__construct()
File
- src/
Entity/ JsonapiResourceConfig.php, line 124
Class
- JsonapiResourceConfig
- Defines the JSON:API Resource Config entity.
Namespace
Drupal\jsonapi_extras\EntityCode
public function getFieldMapping() {
$resource_fields = $this
->get('resourceFields') ?: [];
$mapping = [];
foreach ($resource_fields as $resource_field) {
$field_name = $resource_field['fieldName'];
if ($resource_field['disabled'] === TRUE) {
$mapping[$field_name] = FALSE;
continue;
}
if (($alias = $resource_field['publicName']) && $alias !== $field_name) {
$mapping[$field_name] = $alias;
continue;
}
$mapping[$field_name] = TRUE;
}
return $mapping;
}