Class DefaultCollection.

This is the default implementation of a model collection in DcGeneral. Internally it simply holds an array.

 Methods

Alias for push - Append a model to the end of this collection.

add(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel) : void
deprecated Use push.

Parameters

$objModel

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The model to append to the collection.

Exceptions

\ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralRuntimeException When no model has been passed.

Check whether the given model is contained in the collection.

contains(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $model) : bool

Parameters

Returns

bool

Check whether the given model is contained in the collection.

containsById(mixed $modelId) : bool

Parameters

$modelId

mixed

The model id to search.

Returns

bool

{@inheritdoc}

count() 

Computes the difference of the collection.

diff(\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $collection) : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

Parameters

$collection

\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

The collection to compute the difference for.

Returns

\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterfaceThe collection containing all the entries from this collection that are not present in the given collection.

Get the model at a specific index.

get(int $intIndex) : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

Parameters

$intIndex

int

The index of the model to retrieve.

Returns

Get a iterator for this collection.

getIterator() : \IteratorAggregate

Retrieve the ids of the models.

getModelIds() : array

Returns

array

Insert a record at the specific position.

insert(int $intIndex, \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel) : void
Move all records at position >= $index one index up. If $index is out of bounds, just add at the end (does not fill with empty records!).

Parameters

$intIndex

int

The index where the model shall be placed.

Intersect the given collection with this collection and return the result.

intersect(\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $collection) : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

Check if the given collection is an subset of the given collection.

isSubsetOf(\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $collection) : boolean

Parameters

Returns

boolean

Get length of this collection.

length() : int

Returns

int

{@inheritdoc}

offsetExists($offset) 

Parameters

$offset

{@inheritdoc}

offsetGet($offset) 

Parameters

$offset

{@inheritdoc}

offsetSet($offset, $value) 

Parameters

$offset

$value

{@inheritdoc}

offsetUnset($offset) 

Parameters

$offset

Remove the model at the end of the collection and return it.

pop() : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface
If the collection is empty, null will be returned.

Returns

Append a model to the end of this collection.

push(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel) : void

Parameters

$objModel

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The model to append to the collection.

Exceptions

\ContaoCommunityAlliance\DcGeneral\Exception\DcGeneralRuntimeException When no model has been passed.

Remove the given index or model from the collection and renew the index.

remove(mixed $mixedValue) : void
ATTENTION: Don't use key to unset in foreach because of the new index.

Parameters

$mixedValue

mixed

The index (integer) or InterfaceGeneralModel instance to remove.

Remove the model with the given id from the collection.

removeById(mixed $modelId) : void

Parameters

$modelId

mixed

The id of the model to remove.

Remove the model from the beginning of the collection and return it.

shift() : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface
If the collection is empty, null will be returned.

Returns

Sort the records with the given callback and return the new sorted collection.

sort(callback $callback) : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

Parameters

$callback

callback

The callback function to use.

Returns

Compute the union of this collection and the given collection.

union(\ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface $collection) : \ContaoCommunityAlliance\DcGeneral\Data\CollectionInterface

Insert a model at the beginning of the collection.

unshift(\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface $objModel) : void

Parameters

$objModel

\ContaoCommunityAlliance\DcGeneral\Data\ModelInterface

The model to insert into the collection.

 Properties

 

The list of contained models.

$arrCollection : \ContaoCommunityAlliance\DcGeneral\Data\ModelInterface[]