GraphQL\Examples\Blog\Data\DataSource::findReplies PHP Method

findReplies() public static method

public static findReplies ( $commentId, $limit = 5, $afterId = null )
    public static function findReplies($commentId, $limit = 5, $afterId = null)
    {
        $commentReplies = isset(self::$commentReplies[$commentId]) ? self::$commentReplies[$commentId] : [];
        $start = isset($after) ? (int) array_search($afterId, $commentReplies) + 1 : 0;
        $commentReplies = array_slice($commentReplies, $start, $limit);
        return array_map(function ($replyId) {
            return self::$comments[$replyId];
        }, $commentReplies);
    }

Usage Example

コード例 #1
0
ファイル: CommentType.php プロジェクト: aeshion/ZeroPHP
 public function replies(Comment $comment, $args)
 {
     $args += ['after' => null];
     return DataSource::findReplies($comment->id, $args['limit'], $args['after']);
 }