blob: b9df77e4e286aa6436163e0f96c793f474545045 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace LdapRecord\Query\Pagination;
4
5use LdapRecord\LdapInterface;
6
7class LazyPaginator extends Paginator
8{
9 /**
10 * Execute the pagination request.
11 *
12 * @param LdapInterface $ldap
13 *
Matthias Andreas Benkard1ba53812022-12-27 17:32:58 +010014 * @return \Generator
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020015 */
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 Benkard1ba53812022-12-27 17:32:58 +010030 } while ($this->shouldContinue());
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +020031
32 $this->resetServerControls($ldap);
33 }
34}