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
- (PHP 5 >= 5.1.0) Count elements of an object
- create() : CollectionInterface
- Creates a new collection objects and reconstitutes the given database record to the new object.
- current() : mixed
- (PHP 5 >= 5.1.0) 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
- (PHP 5 >= 5.1.0) 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() : mixed
- (PHP 5 >= 5.1.0) Move forward to next element
- persist() : mixed
- Persists current collection state to underlying storage
- rewind() : mixed
- (PHP 5 >= 5.1.0) Rewind the Iterator to the first element
- serialize() : string
- (PHP 5 >= 5.1.0) String representation of object
- 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
- unserialize() : mixed
- (PHP 5 >= 5.1.0) Constructs the object
- usort() : mixed
- Sorts collection via given callBackFunction
- valid() : bool
- (PHP 5 >= 5.1.0) 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()
(PHP 5 >= 5.1.0) Count elements of an object
public
count() : int
Tags
Attributes
- #[ReturnTypeWillChange]
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()
(PHP 5 >= 5.1.0) Return the current element
public
current() : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —Can return any type.
fromArray()
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()
(PHP 5 >= 5.1.0) Return the key of the current element
public
key() : int|string
Tags
Attributes
- #[ReturnTypeWillChange]
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()
(PHP 5 >= 5.1.0) Move forward to next element
public
next() : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
persist()
Persists current collection state to underlying storage
public
persist() : mixed
rewind()
(PHP 5 >= 5.1.0) Rewind the Iterator to the first element
public
rewind() : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
serialize()
(PHP 5 >= 5.1.0) String representation of object
public
serialize() : string
Tags
Return values
string —the string representation of the object or &null;
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>unserialize()
(PHP 5 >= 5.1.0) Constructs the object
public
unserialize(string $serialized) : mixed
Parameters
- $serialized : string
-
The string representation of the object
Tags
Return values
mixed —the original value unserialized.
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()
(PHP 5 >= 5.1.0) Checks if current position is valid
public
valid() : bool
Tags
Attributes
- #[ReturnTypeWillChange]
Return values
bool —The return value will be casted 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.