ListModelTrait
Provides a `list` reference exposing a {@see ListModel} to the host class.
Mix this trait into a model or service that delegates "list" operations (paginated reads, collection queries, etc.) to a ListModel. The reference can be injected directly or resolved from a DI container service id during initialization, and assertListModel() guards against using it before it is set.
Tags
Table of Contents
Properties
Methods
- assertListModel() : void
- Asserts that the `$list` property has been set.
- initializeListModel() : static
- Initializes the `$list` reference from an initialization array.
Properties
$list
The list model reference used to perform collection/list operations.
public
ListModel|null
$list
Methods
assertListModel()
Asserts that the `$list` property has been set.
protected
assertListModel() : void
Tags
initializeListModel()
Initializes the `$list` reference from an initialization array.
protected
initializeListModel([array<string|int, mixed> $init = [] ][, ContainerInterface|null $container = null ]) : static
The value is read from the ModelParam::LIST key. When it is a non-empty string and the
container holds a matching entry, the service is resolved. The reference is set only if the
resolved value is a ListModel; otherwise it is set to null.
Parameters
- $init : array<string|int, mixed> = []
-
Initialization options (key:
ModelParam::LIST). - $container : ContainerInterface|null = null
-
Optional DI container used to resolve a string service id.
Tags
Return values
static —The current instance, for fluent chaining.