This repository was archived by the owner on Jan 29, 2020. It is now read-only.
File tree 5 files changed +13
-15
lines changed
5 files changed +13
-15
lines changed Original file line number Diff line number Diff line change 9
9
10
10
use Zend \Expressive \Hal \LinkCollection ;
11
11
12
- abstract class AbstractMetadata
12
+ abstract class AbstractMetadata implements MetadataInterface
13
13
{
14
14
use LinkCollection;
15
15
@@ -22,4 +22,9 @@ public function getClass() : string
22
22
{
23
23
return $ this ->class ;
24
24
}
25
+
26
+ public function hasReachedMaxDepth (int $ currentDepth ): bool
27
+ {
28
+ return false ;
29
+ }
25
30
}
Original file line number Diff line number Diff line change 3
3
4
4
namespace Zend \Expressive \Hal \Metadata ;
5
5
6
- interface DepthAwareMetadataInterface
6
+ interface MetadataInterface
7
7
{
8
8
/**
9
- * Returns configured max depth
9
+ * Returns the configured metadata class name
10
10
*
11
- * @return int
11
+ * @return string
12
12
*/
13
- public function getMaxDepth (): int ;
13
+ public function getClass () : string ;
14
14
15
15
/**
16
16
* Determines whenever the current depth level exceeds the allowed max depth
Original file line number Diff line number Diff line change 7
7
8
8
namespace Zend \Expressive \Hal \Metadata ;
9
9
10
- class RouteBasedResourceMetadata extends AbstractResourceMetadata implements DepthAwareMetadataInterface
10
+ class RouteBasedResourceMetadata extends AbstractResourceMetadata
11
11
{
12
12
/** @var string */
13
13
private $ resourceIdentifier ;
@@ -67,11 +67,6 @@ public function setRouteParams(array $routeParams) : void
67
67
$ this ->routeParams = $ routeParams ;
68
68
}
69
69
70
- public function getMaxDepth (): int
71
- {
72
- return $ this ->maxDepth ;
73
- }
74
-
75
70
public function hasReachedMaxDepth (int $ currentDepth ): bool
76
71
{
77
72
return $ currentDepth > $ this ->maxDepth ;
Original file line number Diff line number Diff line change 10
10
use Psr \Http \Message \ServerRequestInterface ;
11
11
use Zend \Expressive \Hal \Metadata \AbstractCollectionMetadata ;
12
12
use Zend \Expressive \Hal \Metadata \AbstractMetadata ;
13
- use Zend \Expressive \Hal \Metadata \DepthAwareMetadataInterface ;
14
- use Zend \Expressive \Hal \Metadata \RouteBasedResourceMetadata ;
15
13
use Zend \Expressive \Hal \ResourceGenerator ;
16
14
use Zend \Hydrator \ExtractionInterface ;
17
15
@@ -40,7 +38,7 @@ private function extractInstance(
40
38
41
39
$ array = $ extractor ->extract ($ instance );
42
40
43
- if ($ metadata instanceof DepthAwareMetadataInterface && $ metadata ->hasReachedMaxDepth ($ depth )) {
41
+ if ($ metadata ->hasReachedMaxDepth ($ depth )) {
44
42
return $ array ;
45
43
}
46
44
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ public function createResource(
47
47
$ routeParams [$ routeIdentifier ] = $ data [$ resourceIdentifier ];
48
48
}
49
49
50
- if ($ metadata instanceof Metadata \DepthAwareMetadataInterface && $ metadata ->hasReachedMaxDepth ($ depth )) {
50
+ if ($ metadata ->hasReachedMaxDepth ($ depth )) {
51
51
$ data = [];
52
52
}
53
53
You can’t perform that action at this time.
0 commit comments