GraphQL\Examples\Blog\Data\DataSource::findComments PHP 메소드

findComments() 공개 정적인 메소드

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

Usage Example

예제 #1
0
 public function comments(Story $story, $args)
 {
     $args += ['after' => null];
     return DataSource::findComments($story->id, $args['limit'], $args['after']);
 }