Oihana PHP

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
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Properties

$list  : ListModel|null
The list model reference used to perform collection/list operations.

Methods

assertListModel()  : void
Asserts that the `$list` property has been set.
initializeListModel()  : static
Initializes the `$list` reference from an initialization array.

Properties

Methods

assertListModel()

Asserts that the `$list` property has been set.

protected assertListModel() : void
Tags
throws
UnexpectedValueException

If the list property is not set.

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
throws
ContainerExceptionInterface

If an error occurs while retrieving an entry from the dependency-injection container.

NotFoundExceptionInterface

If no entry is found for the requested identifier in the container.

Return values
static

The current instance, for fluent chaining.

On this page

Search results