public function ConfigurableResourceType::getResourceFieldConfiguration in JSON:API Extras 8
Same name and namespace in other branches
- 8.3 src/ResourceType/ConfigurableResourceType.php \Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType::getResourceFieldConfiguration()
- 8.2 src/ResourceType/ConfigurableResourceType.php \Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType::getResourceFieldConfiguration()
Get the resource field configuration.
Parameters
string $field_name: The internal field name.
string $from: The realm of the provided field name.
Return value
array The resource field definition. NULL if none can be found.
3 calls to ConfigurableResourceType::getResourceFieldConfiguration()
- ConfigurableResourceType::getFieldEnhancer in src/
ResourceType/ ConfigurableResourceType.php - Get the field enhancer plugin.
- ConfigurableResourceType::isFieldEnabled in src/
ResourceType/ ConfigurableResourceType.php - Checks if a field is enabled or not.
- ConfigurableResourceType::translateFieldName in src/
ResourceType/ ConfigurableResourceType.php - Given the internal or public field name, get the other one.
File
- src/
ResourceType/ ConfigurableResourceType.php, line 140
Class
- ConfigurableResourceType
- Defines a configurable resource type.
Namespace
Drupal\jsonapi_extras\ResourceTypeCode
public function getResourceFieldConfiguration($field_name, $from = 'fieldName') {
$resource_fields = $this->jsonapiResourceConfig
->get('resourceFields');
// Find the resource field in the config entity for the given field name.
$found = array_filter($resource_fields, function ($resource_field) use ($field_name, $from) {
return !empty($resource_field[$from]) && $field_name == $resource_field[$from];
});
if (empty($found)) {
return NULL;
}
return reset($found);
}