protected function extractOffset(ServerRequestInterface $request)
{
$actor = $request->getAttribute('actor');
$queryParams = $request->getQueryParams();
$sort = $this->extractSort($request);
$limit = $this->extractLimit($request);
$filter = $this->extractFilter($request);
if (($near = array_get($queryParams, 'page.near')) > 1) {
if (count($filter) > 1 || !isset($filter['discussion']) || $sort) {
throw new InvalidParameterException('You can only use page[near] with filter[discussion] and the default sort order');
}
$offset = $this->posts->getIndexForNumber($filter['discussion'], $near, $actor);
return max(0, $offset - $limit / 2);
}
return parent::extractOffset($request);
}