comment_id; } public function getAttributes($comment, ContextInterface $context): iterable { return [ 'content' => $comment->content, 'mkdate' => date('c', $comment->mkdate), 'chdate' => date('c', $comment->chdate), ]; } public function getRelationships($comment, ContextInterface $context): iterable { $isPrimary = $context->getPosition()->getLevel() === 0; $relationships = []; if ($isPrimary) { if ($author = \User::find($comment->user_id)) { $relationships[self::REL_AUTHOR] = [ self::RELATIONSHIP_LINKS => [ Link::RELATED => $this->createLinkToResource($author), ], self::RELATIONSHIP_DATA => $author, ]; } if ($news = \StudipNews::find($comment->object_id)) { $relationships[self::REL_NEWS] = [ self::RELATIONSHIP_LINKS => [ Link::RELATED => $this->createLinkToResource($news), ], self::RELATIONSHIP_DATA => $news, ]; } } return $relationships; } }