Avolutions\Orm\EntityCollection
implements CollectionInterface Uses CollectionTraitAn EntityCollection contains all elements of a specific Entity. It provides the methods for filtering and sorting these elements.
Properties
Property | Visibility | Type | Description |
---|---|---|---|
$entity | protected | string | The name of the entity. |
$items | public | array | The items of the Collection. |
Methods
Method | Visibility | Description |
---|---|---|
__construct() | public | Creates a new EntityCollection for the given Entity type and loads the corresponding EntityConfiguration and EntityMapping. |
count() | public | Returns the number of items in the Collection. |
getAll() | public | Returns all previously loaded Entities of the EntityCollection. |
getById() | public | Returns the matching Entity for the given id. |
getFirst() | public | Returns the first Entity of the EntityCollection. |
getLast() | public | Returns the last Entity of the EntityCollection. |
limit() | public | Sets the number of records that should be loaded from the database. |
orderBy() | public | Sets the sorting of the records that should be loaded from the database. Can be called multiple times to sort on multiple columns. |
where() | public | Filters the EntityCollection by the given condition. |
Property Details
Method Details
__construct()
Creates a new EntityCollection for the given Entity type and loads the corresponding EntityConfiguration and EntityMapping.
public
__construct(Application $Application, Database $Database, Logger $Logger[, string|null $entity = null ]) : mixed
Parameters
Application
$Application
Application instance.
Database
$Database
Database instance.
Logger
$Logger
Logger instance.
string|null
$entity
(optional)
count()
Returns the number of items in the Collection.
public
count() : int
Return values
int Returns the number of items in the Collection.getAll()
Returns all previously loaded Entities of the EntityCollection.
public
getAll() : array<string|int, mixed>
Return values
array<string|int, mixed> Returns all previously loaded Entities of the EntityCollection.getById()
Returns the matching Entity for the given id.
public
getById(int $id) : Entity
Parameters
int
$id
The identifier of the Entity.
Return values
Entity Returns the matching Entity for the given id.getFirst()
Returns the first Entity of the EntityCollection.
public
getFirst() : Entity|null
Return values
Entity|null Returns the first Entity of the EntityCollection.getLast()
Returns the last Entity of the EntityCollection.
public
getLast() : Entity
Return values
Entity Returns the last Entity of the EntityCollection.limit()
Sets the number of records that should be loaded from the database.
public
limit(int $rowCount, int $offset) : EntityCollection
Parameters
int
$rowCount
The number of records that should be loaded from the database.
int
$offset
Specifies the offset of the first row to return.
Return values
EntityCollection Sets the number of records that should be loaded from the database.orderBy()
Sets the sorting of the records that should be loaded from the database. Can be called multiple times to sort on multiple columns.
public
orderBy(string $field[, bool $descending = false ]) : EntityCollection
Parameters
string
$field
The name of the Entity property to sort by.
bool
$descending
(optional)
Whether the sort order should be descending or not.
Return values
EntityCollection Sets the sorting of the records that should be loaded from the database. Can be called multiple times to sort on multiple columns.where()
Filters the EntityCollection by the given condition.
public
where(string $condition) : EntityCollection
Parameters
string
$condition
The filter condition.