Skip to content

Commit f44f363

Browse files
committed
Add Context::fieldRequested
1 parent 5753e3a commit f44f363

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Context.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,19 @@ public function getRequest(): ServerRequestInterface
3232
return $this->request;
3333
}
3434

35-
public function response(callable $callback)
35+
public function response(callable $callback): void
3636
{
3737
$this->listeners['response'][] = $callback;
3838
}
39+
40+
public function fieldRequested(string $type, string $field, bool $default = true): bool
41+
{
42+
$queryParams = $this->request->getQueryParams();
43+
44+
if (! isset($queryParams['fields'][$type])) {
45+
return $default;
46+
}
47+
48+
return in_array($field, explode(',', $queryParams['fields'][$type]));
49+
}
3950
}

0 commit comments

Comments
 (0)