CategoryCollection extends AbstractRecordCollection implements EditableCollectionInterface

Category Collection to handle records attached to a category

Table of Contents

Interfaces

EditableCollectionInterface
Interface for collection classes which es enabled to be modified

Properties

$description  : string
Collection description
$itemTableName  : string
Table name of the records stored in this collection
$relationFieldName  : string
Name of the categories-relation field (used in the MM_match_fields/fieldname property of the TCA)
$storage  : SplDoublyLinkedList
The local storage
$storageItemsField  : string
The table name collections are stored to
$storageTableName  : string
The table name collections are stored to
$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
add()  : mixed
Adds on entry to the collection
addAll()  : mixed
Adds a set of entries to the collection
count()  : int
(PHP 5 >= 5.1.0) Count elements of an object
create()  : CategoryCollection
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
getItems()  : array<string|int, mixed>
Gets the current available items.
getItemTableName()  : string
Setter for the name of the data-source table
getRelationFieldName()  : string
Gets the name of the categories relation field
getStorageItemsField()  : string
Getter for the storage items field
getStorageTableName()  : string
Getter for the storage table name
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 For memory reasons, per default only f.e. title, database-table, identifier (what ever static data is defined) is loaded.
loadContents()  : mixed
Populates the content-entries of the storage Queries the underlying storage for entries of the collection and adds them to the collection data.
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
remove()  : mixed
Removes the given entry from collection Note: not the given "index"
removeAll()  : mixed
Removes all entries from the collection collection will be empty afterwards
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
setRelationFieldName()  : mixed
Sets the name of the categories relation field
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
getCollectedRecords()  : array<string|int, mixed>
Gets the collected records in this collection, by using <getCollectedRecordsQueryBuilder>.
getCollectedRecordsQueryBuilder()  : QueryBuilder
Selects the collected records in this collection, by looking up the MM relations of this record to the table name defined in the local field 'table_name'.
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

$relationFieldName

Name of the categories-relation field (used in the MM_match_fields/fieldname property of the TCA)

protected string $relationFieldName = 'categories'

$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

protected static string $storageTableName = 'sys_category'

$title

Collection title

protected string $title

$uid

Uid of the storage

protected int $uid = 0

Methods

__construct()

Creates this object.

public __construct([string $tableName = null ][, string $fieldName = null ]) : mixed
Parameters
$tableName : string = null

Name of the table to be working on

$fieldName : string = null

Name of the field where the categories relations are defined

Tags
throws
RuntimeException

__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>

add()

Adds on entry to the collection

public add(mixed $data) : mixed
Parameters
$data : mixed

addAll()

Adds a set of entries to the collection

public addAll(CollectionInterface $other) : mixed
Parameters
$other : CollectionInterface

count()

(PHP 5 >= 5.1.0) Count elements of an object

public count() : int
Tags
link
https://php.net/manual/en/countable.count.php
todo:

Set return type to in in v12 as breaking patch and drop #[\ReturnTypeWillChange]

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 ]) : CategoryCollection
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
CategoryCollection

current()

(PHP 5 >= 5.1.0) Return the current element

public current() : mixed
Tags
link
https://php.net/manual/en/iterator.current.php
todo:

Set return type to mixed when PHP >= 8.0 is required and drop #[\ReturnTypeWillChange]

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
string

getIdentifier()

Returns the uid of the collection

public getIdentifier() : int
Return values
int

getItems()

Gets the current available items.

public getItems() : array<string|int, mixed>
Return values
array<string|int, mixed>

getItemTableName()

Setter for the name of the data-source table

public getItemTableName() : string
Return values
string

getRelationFieldName()

Gets the name of the categories relation field

public getRelationFieldName() : string
Return values
string

getStorageItemsField()

Getter for the storage items field

public static getStorageItemsField() : string
Return values
string

getStorageTableName()

Getter for the storage table name

public static getStorageTableName() : string
Return values
string

getTitle()

Getter for the title

public getTitle() : string
Return values
string

getUid()

Getter for the UID

public getUid() : int
Return values
int

key()

(PHP 5 >= 5.1.0) Return the key of the current element

public key() : int|string
Tags
link
https://php.net/manual/en/iterator.key.php
todo:

Set return type to mixed when PHP >= 8.0 is required and drop #[\ReturnTypeWillChange]

Attributes
#[ReturnTypeWillChange]
Return values
int|string

0 on failure.

load()

Loads the collections with the given id from persistence For memory reasons, per default only f.e. title, database-table, identifier (what ever static data is defined) is loaded.

public static load(int $id[, bool $fillItems = false ][, string $tableName = '' ][, string $fieldName = '' ]) : CollectionInterface

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

$tableName : string = ''

Name of table from which entries should be loaded

$fieldName : string = ''

Name of the categories relation field

Return values
CollectionInterface

loadContents()

Populates the content-entries of the storage Queries the underlying storage for entries of the collection and adds them to the collection data.

public loadContents() : mixed

If the content entries of the storage had not been loaded on creation ($fillItems = false) this function is to be used for loading the contents afterwards.

moveItemAt()

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

persist()

Persists current collection state to underlying storage

public persist() : mixed

remove()

Removes the given entry from collection Note: not the given "index"

public remove(mixed $data) : mixed
Parameters
$data : mixed

removeAll()

Removes all entries from the collection collection will be empty afterwards

public removeAll() : mixed

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

setRelationFieldName()

Sets the name of the categories relation field

public setRelationFieldName(string $field) : mixed
Parameters
$field : 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
link
https://php.net/manual/en/serializable.unserialize.php
todo:

Drop method and \Serializable (through parent interface) class interface in v12.

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
see
http://www.php.net/manual/en/function.usort.php

valid()

(PHP 5 >= 5.1.0) Checks if current position is valid

public valid() : bool
Tags
link
https://php.net/manual/en/iterator.valid.php
todo:

Set return type to bool in v12 as breaking patch and drop #[\ReturnTypeWillChange]

Attributes
#[ReturnTypeWillChange]
Return values
bool

The return value will be casted to boolean and then evaluated.

getCollectedRecords()

Gets the collected records in this collection, by using <getCollectedRecordsQueryBuilder>.

protected getCollectedRecords() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCollectedRecordsQueryBuilder()

Selects the collected records in this collection, by looking up the MM relations of this record to the table name defined in the local field 'table_name'.

protected getCollectedRecordsQueryBuilder() : QueryBuilder
Return values
QueryBuilder

getCollectionDatabaseTable()

protected static getCollectionDatabaseTable() : string
Return values
string

getItemUidList()

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
string

getPersistableDataArray()

Returns an array of the persistable properties and contents which are processable by DataHandler.

protected getPersistableDataArray() : array<string|int, mixed>

for internal usage in persist only.

Return values
array<string|int, mixed>

        
On this page

Search results