Skip to content

Commit

Permalink
unset better-rest params in query forwarded to kirby api
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Meilick <[email protected]>
  • Loading branch information
bnomei committed Aug 21, 2019
1 parent 5f18392 commit ad57e81
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions classes/Betterrest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,25 @@ public function contentFromRequest(?\Kirby\Http\Request $request = null): ?array
}

// options from query
$queryToOptions = array_merge(\Kirby\Toolkit\A::get($this->options, 'query', []), $request->query()->toArray());
$query = $request->query()->toArray();
$queryToOptions = array_merge(\Kirby\Toolkit\A::get($this->options, 'query', []), $query);
$this->options = array_merge($this->options, $this->optionsFromQuery($queryToOptions));

$queryWithoutBetterRestParams = $query;
foreach($query as $key => $value) {
if (substr($key, 0, 3) === 'br-') {
unset($queryWithoutBetterRestParams[$key]);
}
}

// method api() is @internal
$render = $this->kirby->api()->render(
(string) $path,
(string) $request->method(),
[
// 'body' => $request->body()->toArray(),
'headers' => $request->headers(),
'query' => $request->query()->toArray(),
'query' => $queryWithoutBetterRestParams,
]
);

Expand Down

0 comments on commit ad57e81

Please sign in to comment.