LazyCriteriaCollection
extends AbstractLazyCollection
in package
implements
Selectable
A lazy collection that allows a fast count when using criteria object Once count gets executed once without collection being initialized, result is cached and returned on subsequent calls until collection gets loaded, then returning the number of loaded results.
Tags
Table of Contents
Interfaces
- Selectable
- Interface for collections that allow efficient filtering with an expression API.
Properties
- $collection : Collection<string|int, mixed>|null
- The backed collection to use
- $criteria : Criteria
- $entityPersister : EntityPersister
- $initialized : bool
- $count : int|null
Methods
- __construct() : mixed
- add() : true
- Adds an element at the end of the collection.
- clear() : void
- Clears the collection, removing all elements.
- contains() : mixed
- {@inheritDoc}
- containsKey() : mixed
- {@inheritDoc}
- count() : int
- Do an efficient count on the collection
- current() : mixed
- {@inheritDoc}
- exists() : mixed
- {@inheritDoc}
- filter() : Collection<string|int, mixed>
- Returns all the elements of this collection that satisfy the predicate p.
- first() : mixed
- {@inheritDoc}
- forAll() : mixed
- {@inheritDoc}
- get() : mixed
- {@inheritDoc}
- getIterator() : Traversable<int|string, mixed>
- {@inheritDoc}
- getKeys() : mixed
- {@inheritDoc}
- getValues() : mixed
- {@inheritDoc}
- indexOf() : mixed
- {@inheritDoc}
- isEmpty() : bool
- check if collection is empty without loading it
- isInitialized() : bool
- Is the lazy collection already initialized?
- key() : mixed
- {@inheritDoc}
- last() : mixed
- {@inheritDoc}
- map() : mixed
- {@inheritDoc}
- matching() : Collection<string|int, mixed>|Selectable<string|int, mixed>
- Selects all elements from a selectable that match the expression and returns a new collection containing these elements.
- next() : mixed
- {@inheritDoc}
- offsetExists() : bool
- offsetGet() : mixed
- offsetSet() : void
- offsetUnset() : void
- partition() : array<string|int, Collection<string|int, mixed>>
- Partitions this collection in two collections according to a predicate.
- remove() : mixed
- Removes the element at the specified index from the collection.
- removeElement() : bool
- Removes the specified element from the collection, if it is found.
- set() : void
- Sets an element in the collection at the specified key/index.
- slice() : mixed
- {@inheritDoc}
- toArray() : mixed
- {@inheritDoc}
- doInitialize() : void
- Do the initialization logic
- initialize() : void
- Initialize the collection
Properties
$collection
The backed collection to use
protected
Collection<string|int, mixed>|null
$collection
Tags
$criteria
protected
Criteria
$criteria
$entityPersister
protected
EntityPersister
$entityPersister
$initialized
protected
bool
$initialized
= false
$count
private
int|null
$count
Methods
__construct()
public
__construct(EntityPersister $entityPersister, Criteria $criteria) : mixed
Parameters
- $entityPersister : EntityPersister
- $criteria : Criteria
add()
Adds an element at the end of the collection.
public
add(mixed $element) : true
Parameters
- $element : mixed
-
The element to add.
Return values
true —Always TRUE.
clear()
Clears the collection, removing all elements.
public
clear() : void
contains()
{@inheritDoc}
public
contains(mixed $element) : mixed
Do an optimized search of an element
Parameters
- $element : mixed
Tags
containsKey()
{@inheritDoc}
public
containsKey(mixed $key) : mixed
Parameters
- $key : mixed
count()
Do an efficient count on the collection
public
count() : int
Return values
intcurrent()
{@inheritDoc}
public
current() : mixed
exists()
{@inheritDoc}
public
exists(Closure $p) : mixed
Parameters
- $p : Closure
filter()
Returns all the elements of this collection that satisfy the predicate p.
public
filter(Closure $p) : Collection<string|int, mixed>
Parameters
- $p : Closure
-
The predicate used for filtering.
Return values
Collection<string|int, mixed> —A collection with the results of the filter operation.
first()
{@inheritDoc}
public
first() : mixed
forAll()
{@inheritDoc}
public
forAll(Closure $p) : mixed
Parameters
- $p : Closure
get()
{@inheritDoc}
public
get(mixed $key) : mixed
Parameters
- $key : mixed
getIterator()
{@inheritDoc}
public
getIterator() : Traversable<int|string, mixed>
Tags
Return values
Traversable<int|string, mixed>getKeys()
{@inheritDoc}
public
getKeys() : mixed
getValues()
{@inheritDoc}
public
getValues() : mixed
indexOf()
{@inheritDoc}
public
indexOf(mixed $element) : mixed
Parameters
- $element : mixed
Tags
isEmpty()
check if collection is empty without loading it
public
isEmpty() : bool
Return values
bool —TRUE if the collection is empty, FALSE otherwise.
isInitialized()
Is the lazy collection already initialized?
public
isInitialized() : bool
Tags
Return values
boolkey()
{@inheritDoc}
public
key() : mixed
last()
{@inheritDoc}
public
last() : mixed
map()
{@inheritDoc}
public
map(Closure $func) : mixed
Parameters
- $func : Closure
matching()
Selects all elements from a selectable that match the expression and returns a new collection containing these elements.
public
matching(Criteria $criteria) : Collection<string|int, mixed>|Selectable<string|int, mixed>
Parameters
- $criteria : Criteria
Return values
Collection<string|int, mixed>|Selectable<string|int, mixed>next()
{@inheritDoc}
public
next() : mixed
offsetExists()
public
offsetExists(TKey $offset) : bool
Parameters
- $offset : TKey
Return values
booloffsetGet()
public
offsetGet(TKey $offset) : mixed
Parameters
- $offset : TKey
offsetSet()
public
offsetSet(TKey|null $offset, T $value) : void
Parameters
- $offset : TKey|null
- $value : T
offsetUnset()
public
offsetUnset(TKey $offset) : void
Parameters
- $offset : TKey
partition()
Partitions this collection in two collections according to a predicate.
public
partition(Closure $p) : array<string|int, Collection<string|int, mixed>>
Parameters
- $p : Closure
-
The predicate on which to partition.
Return values
array<string|int, Collection<string|int, mixed>> —An array with two elements. The first element contains the collection of elements where the predicate returned TRUE, the second element contains the collection of elements where the predicate returned FALSE.
remove()
Removes the element at the specified index from the collection.
public
remove(mixed $key) : mixed
Parameters
- $key : mixed
-
The key/index of the element to remove.
Return values
mixed —The removed element or NULL, if the collection did not contain the element.
removeElement()
Removes the specified element from the collection, if it is found.
public
removeElement(mixed $element) : bool
Parameters
- $element : mixed
-
The element to remove.
Return values
bool —TRUE if this collection contained the specified element, FALSE otherwise.
set()
Sets an element in the collection at the specified key/index.
public
set(mixed $key, mixed $value) : void
Parameters
- $key : mixed
-
The key/index of the element to set.
- $value : mixed
-
The element to set.
slice()
{@inheritDoc}
public
slice(mixed $offset[, mixed $length = null ]) : mixed
Parameters
- $offset : mixed
- $length : mixed = null
toArray()
{@inheritDoc}
public
toArray() : mixed
doInitialize()
Do the initialization logic
protected
doInitialize() : void
initialize()
Initialize the collection
protected
initialize() : void