Skip to content

Commit

Permalink
added max_depth config param to resource metadata factories
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Trozowski <tobias@trozowski.com>
  • Loading branch information
tobias-trozowski authored and weierophinney committed Dec 21, 2020
1 parent c371798 commit 53dc80b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/Metadata/RouteBasedResourceMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class RouteBasedResourceMetadataFactory implements MetadataFactoryInterface
* // 'route_identifier_placeholder' setting, which will be removed
* // in version 2.0.
* 'identifiers_to_placeholders_mapping' => ['id' => 'id'],
*
* // Max depth to render
* // Defaults to 10.
* 'max_depth' => 10,
* ]
* </code>
* @return AbstractMetadata
Expand Down Expand Up @@ -82,7 +86,8 @@ public function createMetadata(string $requestedName, array $metadata) : Abstrac
$metadata['resource_identifier'] ?? 'id',
$metadata['route_identifier_placeholder'] ?? 'id',
$metadata['route_params'] ?? [],
$metadata['identifiers_to_placeholders_mapping'] ?? ['id' => 'id']
$metadata['identifiers_to_placeholders_mapping'] ?? ['id' => 'id'],
$metadata['max_depth'] ?? 10
);
}
}
7 changes: 6 additions & 1 deletion src/Metadata/UrlBasedResourceMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class UrlBasedResourceMetadataFactory implements MetadataFactoryInterface
*
* // The extractor/hydrator service to use to extract resource data.
* 'extractor' => 'MyExtractor',
*
* // Max depth to render
* // Defaults to 10.
* 'max_depth' => 10,
* ]
* </code>
* @return AbstractMetadata
Expand All @@ -55,7 +59,8 @@ public function createMetadata(string $requestedName, array $metadata) : Abstrac
return new $requestedName(
$metadata['resource_class'],
$metadata['url'],
$metadata['extractor']
$metadata['extractor'],
$metadata['max_depth'] ?? 10
);
}
}

0 comments on commit 53dc80b

Please sign in to comment.