controlPagedResultResponse() public method

Retrieve a paginated result response.
public controlPagedResultResponse ( $result, string &$cookie ) : mixed
$result
$cookie string
return mixed
Example #1
0
 /**
  * Paginates the current LDAP query.
  *
  * @param int  $perPage
  * @param int  $currentPage
  * @param bool $isCritical
  *
  * @return Paginator|bool
  */
 public function paginate($perPage = 50, $currentPage = 0, $isCritical = true)
 {
     $this->paginated = true;
     $pages = [];
     $cookie = '';
     do {
         $this->connection->controlPagedResult($perPage, $isCritical, $cookie);
         // Run the search.
         $resource = $this->connection->search($this->getDn(), $this->getQuery(), $this->getSelects());
         if ($resource) {
             $this->connection->controlPagedResultResponse($resource, $cookie);
             // We'll collect each resource result into the pages array.
             $pages[] = $resource;
         }
     } while (!empty($cookie));
     $paginator = $this->newProcessor()->processPaginated($pages, $perPage, $currentPage);
     // Reset paged result on the current connection. We won't pass in the current $perPage
     // parameter since we want to reset the page size to the default '1000'. Sending '0'
     // eliminates any further opportunity for running queries in the same request,
     // even though that is supposed to be the correct usage.
     $this->connection->controlPagedResult();
     return $paginator;
 }
Example #2
0
 /**
  * Paginates the current LDAP query.
  *
  * @param int  $perPage
  * @param int  $currentPage
  * @param bool $isCritical
  *
  * @return Paginator|bool
  */
 public function paginate($perPage = 50, $currentPage = 0, $isCritical = true)
 {
     // Stores all LDAP entries in a page array
     $pages = [];
     $cookie = '';
     do {
         $this->connection->controlPagedResult($perPage, $isCritical, $cookie);
         $results = $this->connection->search($this->getDn(), $this->getQuery(), $this->getSelects());
         if ($results) {
             $this->connection->controlPagedResultResponse($results, $cookie);
             $pages[] = $results;
         }
     } while ($cookie !== null && !empty($cookie));
     if (count($pages) > 0) {
         return $this->processPaginatedResults($pages, $perPage, $currentPage);
     }
     return false;
 }