Skip to content

Latest commit

 

History

History
65 lines (43 loc) · 1.25 KB

result_pager.md

File metadata and controls

65 lines (43 loc) · 1.25 KB

Result Pager

Back to the navigation

Usage examples

Get all repositories of an organization

$client = new Github\Client();

$organizationApi = $client->api('organization');

$paginator  = new Github\ResultPager($client);
$parameters = array('github');
$result     = $paginator->fetchAll($organizationApi, 'repositories', $parameters);

Parameters of the fetchAll method:

  • The API object you're working with
  • The method of the API object you're using
  • The parameters of the method

Parameters are passed to the API method via call_user_func_array.

$parameters = array('github', 'all', 1); // $organization, $type, $page

Get the first page

$client = new Github\Client();

$organizationApi = $client->api('organization');

$paginator  = new Github\ResultPager( $client );
$parameters = array('github');
$result     = $paginator->fetch($organizationApi, 'repositories', $parameters);

Check for a next page:

$paginator->hasNext();

Get next page:

$paginator->fetchNext();

Check for previous page:

$paginator->hasPrevious();

Get previous page:

$paginator->fetchPrevious();