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

findComments() public static method

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
ファイル: StoryType.php プロジェクト: aeshion/ZeroPHP
 public function comments(Story $story, $args)
 {
     $args += ['after' => null];
     return DataSource::findComments($story->id, $args['limit'], $args['after']);
 }