HumHub Documentation (unofficial)

DefaultIterator
in package
implements Iterator, Countable

Laminas\Ldap\Collection\DefaultIterator is the default collection iterator implementation using ext/ldap

Tags
template-implements

Iterator<string, array{dn: string, ...}>

Table of Contents

Interfaces

Iterator
Countable

Constants

ATTRIBUTE_NATIVE  = 3
ATTRIBUTE_TO_LOWER  = 1
ATTRIBUTE_TO_UPPER  = 2

Properties

$attributeNameTreatment  : int|callable
The method that will be applied to the attribute's names.
$current  : resource|null
Current result entry identifier
$entries  : array<string|int, mixed>
This array holds a list of resources and sorting-values.
$itemCount  : int
Number of items in query result
$ldap  : Ldap
LDAP Connection
$resultId  : resource|null
Result identifier resource
$sortFunction  : callable
The function to sort the entries by

Methods

__construct()  : mixed
__destruct()  : mixed
close()  : bool
Closes the current result set
count()  : mixed
current()  : mixed
getAttributeNameTreatment()  : int|callable
Returns the currently set attribute name treatment
getLDAP()  : Ldap
Gets the current LDAP connection.
key()  : mixed
next()  : mixed
rewind()  : mixed
setAttributeNameTreatment()  : DefaultIterator
Sets the attribute name treatment.
setSortFunction()  : DefaultIterator
Set a sorting-algorithm for this iterator
sort()  : void
Sort the iterator
valid()  : mixed

Constants

Properties

$attributeNameTreatment

The method that will be applied to the attribute's names.

protected int|callable $attributeNameTreatment = self::ATTRIBUTE_TO_LOWER

$current

Current result entry identifier

protected resource|null $current

$entries

This array holds a list of resources and sorting-values.

protected array<string|int, mixed> $entries = []

Each result is represented by an array containing the keys resource which holds a resource of a result-item and the key sortValue which holds the value by which the array will be sorted.

The resources will be filled on creating the instance and the sorting values on sorting.

$itemCount

Number of items in query result

protected int $itemCount = -1

$resultId

Result identifier resource

protected resource|null $resultId

$sortFunction

The function to sort the entries by

protected callable $sortFunction

Methods

close()

Closes the current result set

public close() : bool
Return values
bool

getAttributeNameTreatment()

Returns the currently set attribute name treatment

public getAttributeNameTreatment() : int|callable
Return values
int|callable

setAttributeNameTreatment()

Sets the attribute name treatment.

public setAttributeNameTreatment(int|callable $attributeNameTreatment) : DefaultIterator

Can either be one of the following constants

  • Laminas\Ldap\Collection\DefaultIterator::ATTRIBUTE_TO_LOWER
  • Laminas\Ldap\Collection\DefaultIterator::ATTRIBUTE_TO_UPPER
  • Laminas\Ldap\Collection\DefaultIterator::ATTRIBUTE_NATIVE or a valid callback accepting the attribute's name as it's only argument and returning the new attribute's name.
Parameters
$attributeNameTreatment : int|callable
Return values
DefaultIterator

Provides a fluent interface

setSortFunction()

Set a sorting-algorithm for this iterator

public setSortFunction(callable $sortFunction) : DefaultIterator

The callable has to accept two parameters that will be compared.

Parameters
$sortFunction : callable

The algorithm to be used for sorting

Return values
DefaultIterator

Provides a fluent interface

sort()

Sort the iterator

public sort(string $sortAttribute) : void

Sorting is done using the set sortFunction which is by default strnatcasecmp.

The attribute is determined by lowercasing everything.

The sort-value will be the first value of the attribute.

Parameters
$sortAttribute : string

The attribute to sort by. If not given the value set via setSortAttribute is used.


        
On this page

Search results