/**
* {@inheritdoc}
*/
protected function data(ServerRequestInterface $request, Document $document)
{
$actor = $request->getAttribute('actor');
$filter = $this->extractFilter($request);
$include = $this->extractInclude($request);
$where = [];
if ($postIds = array_get($filter, 'id')) {
$posts = $this->posts->findByIds(explode(',', $postIds), $actor);
} else {
if ($discussionId = array_get($filter, 'discussion')) {
$where['discussion_id'] = $discussionId;
}
if ($number = array_get($filter, 'number')) {
$where['number'] = $number;
}
if ($userId = array_get($filter, 'user')) {
$where['user_id'] = $userId;
}
if ($type = array_get($filter, 'type')) {
$where['type'] = $type;
}
$posts = $this->getPosts($request, $where);
}
return $posts->load($include);
}