blob: 2974b8fd609872c1b4fb3ec8ae22a8e5a613b448 [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 *
14 * @return Generator
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);
30 } while (! empty($this->fetchCookie()));
31
32 $this->resetServerControls($ldap);
33 }
34}