@@ -29,11 +29,17 @@ public function __construct(JsonApi $api, ServerRequestInterface $request)
29
29
$ this ->request = $ request ;
30
30
}
31
31
32
+ /**
33
+ * Get the JsonApi instance.
34
+ */
32
35
public function getApi (): JsonApi
33
36
{
34
37
return $ this ->api ;
35
38
}
36
39
40
+ /**
41
+ * Get the PSR-7 request instance.
42
+ */
37
43
public function getRequest (): ServerRequestInterface
38
44
{
39
45
return $ this ->request ;
@@ -44,6 +50,9 @@ public function withRequest(ServerRequestInterface $request): Context
44
50
return new static ($ this ->api , $ request );
45
51
}
46
52
53
+ /**
54
+ * Get the request path relative to the API's base path.
55
+ */
47
56
public function getPath (): string
48
57
{
49
58
return $ this ->api ->stripBasePath (
@@ -56,6 +65,9 @@ public function response(callable $callback): void
56
65
$ this ->listeners ['response ' ][] = $ callback ;
57
66
}
58
67
68
+ /**
69
+ * Determine whether a field has been requested in a sparse fieldset.
70
+ */
59
71
public function fieldRequested (string $ type , string $ field , bool $ default = true ): bool
60
72
{
61
73
$ queryParams = $ this ->request ->getQueryParams ();
@@ -66,4 +78,12 @@ public function fieldRequested(string $type, string $field, bool $default = true
66
78
67
79
return in_array ($ field , explode (', ' , $ queryParams ['fields ' ][$ type ]));
68
80
}
81
+
82
+ /**
83
+ * Get the value of a filter.
84
+ */
85
+ public function filter (string $ name ): ?string
86
+ {
87
+ return $ this ->request ->getQueryParams ()['filter ' ][$ name ] ?? null ;
88
+ }
69
89
}
0 commit comments