This repository was archived by the owner on Jan 29, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +13
-15
lines changed Expand file tree Collapse file tree 5 files changed +13
-15
lines changed Original file line number Diff line number Diff line change 99
1010use Zend \Expressive \Hal \LinkCollection ;
1111
12- abstract class AbstractMetadata
12+ abstract class AbstractMetadata implements MetadataInterface
1313{
1414 use LinkCollection;
1515
@@ -22,4 +22,9 @@ public function getClass() : string
2222 {
2323 return $ this ->class ;
2424 }
25+
26+ public function hasReachedMaxDepth (int $ currentDepth ): bool
27+ {
28+ return false ;
29+ }
2530}
Original file line number Diff line number Diff line change 33
44namespace Zend \Expressive \Hal \Metadata ;
55
6- interface DepthAwareMetadataInterface
6+ interface MetadataInterface
77{
88 /**
9- * Returns configured max depth
9+ * Returns the configured metadata class name
1010 *
11- * @return int
11+ * @return string
1212 */
13- public function getMaxDepth (): int ;
13+ public function getClass () : string ;
1414
1515 /**
1616 * Determines whenever the current depth level exceeds the allowed max depth
Original file line number Diff line number Diff line change 77
88namespace Zend \Expressive \Hal \Metadata ;
99
10- class RouteBasedResourceMetadata extends AbstractResourceMetadata implements DepthAwareMetadataInterface
10+ class RouteBasedResourceMetadata extends AbstractResourceMetadata
1111{
1212 /** @var string */
1313 private $ resourceIdentifier ;
@@ -67,11 +67,6 @@ public function setRouteParams(array $routeParams) : void
6767 $ this ->routeParams = $ routeParams ;
6868 }
6969
70- public function getMaxDepth (): int
71- {
72- return $ this ->maxDepth ;
73- }
74-
7570 public function hasReachedMaxDepth (int $ currentDepth ): bool
7671 {
7772 return $ currentDepth > $ this ->maxDepth ;
Original file line number Diff line number Diff line change 1010use Psr \Http \Message \ServerRequestInterface ;
1111use Zend \Expressive \Hal \Metadata \AbstractCollectionMetadata ;
1212use Zend \Expressive \Hal \Metadata \AbstractMetadata ;
13- use Zend \Expressive \Hal \Metadata \DepthAwareMetadataInterface ;
14- use Zend \Expressive \Hal \Metadata \RouteBasedResourceMetadata ;
1513use Zend \Expressive \Hal \ResourceGenerator ;
1614use Zend \Hydrator \ExtractionInterface ;
1715
@@ -40,7 +38,7 @@ private function extractInstance(
4038
4139 $ array = $ extractor ->extract ($ instance );
4240
43- if ($ metadata instanceof DepthAwareMetadataInterface && $ metadata ->hasReachedMaxDepth ($ depth )) {
41+ if ($ metadata ->hasReachedMaxDepth ($ depth )) {
4442 return $ array ;
4543 }
4644
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public function createResource(
4747 $ routeParams [$ routeIdentifier ] = $ data [$ resourceIdentifier ];
4848 }
4949
50- if ($ metadata instanceof Metadata \DepthAwareMetadataInterface && $ metadata ->hasReachedMaxDepth ($ depth )) {
50+ if ($ metadata ->hasReachedMaxDepth ($ depth )) {
5151 $ data = [];
5252 }
5353
You can’t perform that action at this time.
0 commit comments