function ResourceType::getRelatableResourceTypes
Same name in other branches
- 9 core/modules/jsonapi/src/ResourceType/ResourceType.php \Drupal\jsonapi\ResourceType\ResourceType::getRelatableResourceTypes()
- 8.9.x core/modules/jsonapi/src/ResourceType/ResourceType.php \Drupal\jsonapi\ResourceType\ResourceType::getRelatableResourceTypes()
- 11.x core/modules/jsonapi/src/ResourceType/ResourceType.php \Drupal\jsonapi\ResourceType\ResourceType::getRelatableResourceTypes()
Get all resource types with which this type may have a relationship.
Return value
array The relatable resource types, keyed by relationship field names.
See also
self::setRelatableResourceTypes()
File
-
core/
modules/ jsonapi/ src/ ResourceType/ ResourceType.php, line 403
Class
- ResourceType
- Value object containing all metadata for a JSON:API resource type.
Namespace
Drupal\jsonapi\ResourceTypeCode
public function getRelatableResourceTypes() {
if (!isset($this->relatableResourceTypesByField)) {
$this->relatableResourceTypesByField = array_reduce(array_map(function (ResourceTypeRelationship $field) {
return [
$field->getPublicName() => $field->getRelatableResourceTypes(),
];
}, array_filter($this->fields, function (ResourceTypeField $field) {
return $field instanceof ResourceTypeRelationship && $field->isFieldEnabled();
})), 'array_merge', []);
}
return $this->relatableResourceTypesByField;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.