public function ConfigurableResourceType::getResourceFieldConfiguration in JSON:API Extras 8.2
Same name and namespace in other branches
- 8.3 src/ResourceType/ConfigurableResourceType.php \Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType::getResourceFieldConfiguration()
- 8 src/ResourceType/ConfigurableResourceType.php \Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType::getResourceFieldConfiguration()
Get the resource field configuration.
@todo https://www.drupal.org/node/3007820
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 - @todo Remove this when JSON API Extras drops support for JSON API 1.x.
- ConfigurableResourceType::translateFieldName in src/
ResourceType/ ConfigurableResourceType.php - Given the internal or public field name, get the other one.
File
- src/
ResourceType/ ConfigurableResourceType.php, line 138
Class
- ConfigurableResourceType
- Defines a configurable resource type.
Namespace
Drupal\jsonapi_extras\ResourceTypeCode
public function getResourceFieldConfiguration($field_name, $from = 'fieldName') {
$cid = "{$field_name}:{$from}";
if (isset($this->cache[$cid]) || array_key_exists($cid, $this->cache)) {
return $this->cache[$cid];
}
$resource_fields = $this
->getJsonapiResourceConfig()
->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];
});
$result = empty($found) ? NULL : reset($found);
$this->cache[$cid] = $result;
return $result;
}