diff --git a/src/JsonApiResource/ResourceObject.php b/src/JsonApiResource/ResourceObject.php index 2bad23b..08a9be2 100644 --- a/src/JsonApiResource/ResourceObject.php +++ b/src/JsonApiResource/ResourceObject.php @@ -180,10 +180,12 @@ final class ResourceObject implements CacheableDependencyInterface, ResourceIden $enabled_public_fields = []; $fields = $entity->toArray(); // Filter the array based on the field names. - $enabled_field_names = array_filter( - array_keys($fields), - [$this->resourceType, 'isFieldEnabled'] - ); + $enabled_field_names = array_filter(array_keys($fields), function ($internal_field_name) { + // Config entities have "fields" which aren't known to the resource type, + // these fields should not be excluded because they cannot be enabled or + // disabled. + return !$this->resourceType->hasField($internal_field_name) || $this->resourceType->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)); /* @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */