Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | namespace LdapRecord\Query\Pagination; |
| 4 | |
| 5 | use LdapRecord\LdapInterface; |
| 6 | |
| 7 | class LazyPaginator extends Paginator |
| 8 | { |
| 9 | /** |
| 10 | * Execute the pagination request. |
| 11 | * |
| 12 | * @param LdapInterface $ldap |
| 13 | * |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 14 | * @return \Generator |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 15 | */ |
| 16 | public function execute(LdapInterface $ldap) |
| 17 | { |
| 18 | $this->prepareServerControls(); |
| 19 | |
| 20 | do { |
| 21 | $this->applyServerControls($ldap); |
| 22 | |
| 23 | if (! $resource = $this->query->run($this->filter)) { |
| 24 | break; |
| 25 | } |
| 26 | |
| 27 | $this->updateServerControls($ldap, $resource); |
| 28 | |
| 29 | yield $this->query->parse($resource); |
Matthias Andreas Benkard | 1ba5381 | 2022-12-27 17:32:58 +0100 | [diff] [blame^] | 30 | } while ($this->shouldContinue()); |
Matthias Andreas Benkard | 7b2a3a1 | 2021-08-16 10:57:25 +0200 | [diff] [blame] | 31 | |
| 32 | $this->resetServerControls($ldap); |
| 33 | } |
| 34 | } |