Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify ResultPager instantiation #46

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ class Foo
app(Foo::class)->bar();
```

When the amount of items you receive is not sufficient, you may use the `Gitlab\ResultPager` like so:

```php
$pager = GitLab::resultPager();
$issues = $pager->fetchAll($client->issues(), 'all', [null, ['state' => 'closed']]);
```

For more information on how to use the `Gitlab\Client` class we are calling behind the scenes here, check out the docs at https://github.com/GitLabPHP/Client/tree/11.13.0#general-api-usage, and the manager class at https://github.com/GrahamCampbell/Laravel-Manager#usage.

##### Further Information
Expand Down
13 changes: 13 additions & 0 deletions src/GitLabManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace GrahamCampbell\GitLab;

use Gitlab\Client;
use Gitlab\ResultPager;
use GrahamCampbell\Manager\AbstractManager;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Support\Arr;
Expand Down Expand Up @@ -86,6 +87,18 @@ public function __construct(Repository $config, GitLabFactory $factory)
$this->factory = $factory;
}

/**
* Instantiate a result pager.
*
* @param string|null $connectionName
*
* @return \Gitlab\ResultPager
*/
public function resultPager(?string $connectionName = null): ResultPager
{
return new ResultPager($this->connection($connectionName));
}

/**
* Create the connection instance.
*
Expand Down
Loading