Skip to content

Instantly share code, notes, and snippets.

@huyby
Created November 8, 2017 16:15
Show Gist options
  • Save huyby/9b132cbc26ec0201a0c9cb01c7fc1e72 to your computer and use it in GitHub Desktop.
Save huyby/9b132cbc26ec0201a0c9cb01c7fc1e72 to your computer and use it in GitHub Desktop.
Temp 'fix' to allow related resource endpoints keep using nested include resources (e.g. field_image,field_image.uid)
diff --git a/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php b/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php
index e74b26a..1e4bb69 100644
--- a/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php
+++ b/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php
@@ -247,6 +247,8 @@ class JsonApiDocumentTopLevelNormalizer extends NormalizerBase implements Denorm
protected function expandContext(Request $request, ResourceType $resource_type) {
// Translate ALL the includes from the public field names to the internal.
$includes = array_filter(explode(',', $request->query->get('include')));
+ $public_includes = $includes;
+ /*
$public_includes = array_map(function ($include_str) use ($resource_type) {
$resolved = $this->fieldResolver->resolveInternal(
$resource_type->getEntityTypeId(),
@@ -256,6 +258,7 @@ class JsonApiDocumentTopLevelNormalizer extends NormalizerBase implements Denorm
// We don't need the entity information for the includes. Clean it.
return preg_replace('/\.entity\./', '.', $resolved);
}, $includes);
+ */
// Build the expanded context.
$context = [
'account' => NULL,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment