AbstractRecordCollection implements RecordCollectionInterface, PersistableCollectionInterface, SortableCollectionInterface
Abstract implementation of a RecordCollection
RecordCollection is a collections of TCA-Records. The collection is meant to be stored in TCA-table sys_file_collections and is manageable via FormEngine.
A RecordCollection might be used to group a set of records (e.g. news, images, contentElements) for output in frontend
The AbstractRecordCollection uses SplDoublyLinkedList for internal storage
Tags
Table of Contents
Interfaces
- RecordCollectionInterface
- Collection for handling records from a single database-table.
- PersistableCollectionInterface
- Interface for collection class being persistable
- SortableCollectionInterface
- Interface for collection class being sortable
Properties
- $description : string
- Collection description
- $itemTableName : string
- Table name of the records stored in this collection
- $storage : SplDoublyLinkedList
- The local storage
- $storageItemsField : string
- The table name collections are stored to
- $storageTableName : string
- The table name collections are stored to, must be defined in the subclass
- $title : string
- Collection title
- $uid : int
- Uid of the storage
Methods
- __construct() : mixed
- Creates this object.
- __serialize() : array<string|int, mixed>
- Returns class state to be serialized.
- __unserialize() : void
- Load records with the given serialized information
- count() : int
- Count elements of an object
- create() : CollectionInterface
- Creates a new collection objects and reconstitutes the given database record to the new object.
- current() : T|null
- Return the current element
- fromArray() : mixed
- Loads the properties of this collection from an array
- getDescription() : string
- Getter for the description
- getIdentifier() : int
- Returns the uid of the collection
- getItemTableName() : string
- Setter for the name of the data-source table
- getTitle() : string
- Getter for the title
- getUid() : int
- Getter for the UID
- key() : int|string
- Return the key of the current element
- load() : CollectionInterface
- Loads the collections with the given id from persistence
- moveItemAt() : mixed
- Moves the item within the collection
- next() : void
- Move forward to next element
- persist() : mixed
- Persists current collection state to underlying storage
- rewind() : void
- Rewind the Iterator to the first element
- setDescription() : mixed
- Setter for the description
- setIdentifier() : mixed
- Sets the identifier of the collection
- setItemTableName() : mixed
- Setter for the name of the data-source table
- setTitle() : mixed
- Setter for the title
- toArray() : array<string|int, mixed>
- Builds an array representation of this collection
- usort() : mixed
- Sorts collection via given callBackFunction
- valid() : bool
- Checks if current position is valid
- getCollectionDatabaseTable() : string
- getItemUidList() : string
- Generates comma-separated list of entry uids for usage in DataHandler
- getPersistableDataArray() : array<string|int, mixed>
- Returns an array of the persistable properties and contents which are processable by DataHandler.
Properties
$description
Collection description
protected
string
$description
$itemTableName
Table name of the records stored in this collection
protected
string
$itemTableName
$storage
The local storage
protected
SplDoublyLinkedList
$storage
$storageItemsField
The table name collections are stored to
protected
static string
$storageItemsField
= 'items'
$storageTableName
The table name collections are stored to, must be defined in the subclass
protected
static string
$storageTableName
= ''
$title
Collection title
protected
string
$title
$uid
Uid of the storage
protected
int
$uid
= 0
Methods
__construct()
Creates this object.
public
__construct() : mixed
__serialize()
Returns class state to be serialized.
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__unserialize()
Load records with the given serialized information
public
__unserialize(array<string|int, mixed> $arrayRepresentation) : void
Parameters
- $arrayRepresentation : array<string|int, mixed>
count()
Count elements of an object
public
count() : int
Return values
int —The custom count as an integer.
create()
Creates a new collection objects and reconstitutes the given database record to the new object.
public
static create(array<string|int, mixed> $collectionRecord[, bool $fillItems = false ]) : CollectionInterface
Parameters
- $collectionRecord : array<string|int, mixed>
-
Database record
- $fillItems : bool = false
-
Populates the entries directly on load, might be bad for memory on large collections
Return values
CollectionInterfacecurrent()
Return the current element
public
current() : T|null
Return values
T|nullfromArray()
Loads the properties of this collection from an array
public
fromArray(array<string|int, mixed> $array) : mixed
Parameters
- $array : array<string|int, mixed>
getDescription()
Getter for the description
public
getDescription() : string
Return values
stringgetIdentifier()
Returns the uid of the collection
public
getIdentifier() : int
Return values
intgetItemTableName()
Setter for the name of the data-source table
public
getItemTableName() : string
Return values
stringgetTitle()
Getter for the title
public
getTitle() : string
Return values
stringgetUid()
Getter for the UID
public
getUid() : int
Return values
intkey()
Return the key of the current element
public
key() : int|string
Return values
int|string —0 on failure.
load()
Loads the collections with the given id from persistence
public
static load(int $id[, bool $fillItems = false ]) : CollectionInterface
For memory reasons, per default only f.e. title, database-table, identifier (what ever static data is defined) is loaded. Entries can be load on first access.
Parameters
- $id : int
-
Id of database record to be loaded
- $fillItems : bool = false
-
Populates the entries directly on load, might be bad for memory on large collections
Return values
CollectionInterfacemoveItemAt()
Moves the item within the collection
public
moveItemAt(int $currentPosition[, int $newPosition = 0 ]) : mixed
the item at $currentPosition will be moved to $newPosition. Omitting $newPosition will move to top.
Parameters
- $currentPosition : int
- $newPosition : int = 0
next()
Move forward to next element
public
next() : void
persist()
Persists current collection state to underlying storage
public
persist() : mixed
rewind()
Rewind the Iterator to the first element
public
rewind() : void
setDescription()
Setter for the description
public
setDescription(string $desc) : mixed
Parameters
- $desc : string
setIdentifier()
Sets the identifier of the collection
public
setIdentifier(int $id) : mixed
Parameters
- $id : int
setItemTableName()
Setter for the name of the data-source table
public
setItemTableName(string $tableName) : mixed
Parameters
- $tableName : string
setTitle()
Setter for the title
public
setTitle(string $title) : mixed
Parameters
- $title : string
toArray()
Builds an array representation of this collection
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>usort()
Sorts collection via given callBackFunction
public
usort(callable $callbackFunction) : mixed
The comparison function given as must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.
Parameters
- $callbackFunction : callable
Tags
valid()
Checks if current position is valid
public
valid() : bool
Return values
bool —The return value will be cast to boolean and then evaluated.
getCollectionDatabaseTable()
protected
static getCollectionDatabaseTable() : string
Return values
stringgetItemUidList()
Generates comma-separated list of entry uids for usage in DataHandler
protected
getItemUidList([bool $includeTableName = true ]) : string
also allow to add table name, if it might be needed by DataHandler for storing the relation
Parameters
- $includeTableName : bool = true
Return values
stringgetPersistableDataArray()
Returns an array of the persistable properties and contents which are processable by DataHandler.
protected
abstract getPersistableDataArray() : array<string|int, mixed>
For internal usage in persist only.