CallbackChoiceLoader
in package
implements
ChoiceLoaderInterface
Loads an {@link ArrayChoiceList} instance from a callable returning an array of choices.
Tags
Interfaces, Classes, Traits and Enums
- ChoiceLoaderInterface
- Loads a choice list.
Table of Contents
- $callback : mixed
- $choiceList : ArrayChoiceList
- The loaded choice list.
- __construct() : mixed
- loadChoiceList() : ChoiceListInterface
- Loads a list of choices.
- loadChoicesForValues() : array<string|int, mixed>
- Loads the choices corresponding to the given values.
- loadValuesForChoices() : array<string|int, string>
- Loads the values corresponding to the given choices.
Properties
$callback
private
mixed
$callback
$choiceList
The loaded choice list.
private
ArrayChoiceList
$choiceList
Methods
__construct()
public
__construct(callable $callback) : mixed
Parameters
- $callback : callable
-
The callable returning an array of choices
Return values
mixed —loadChoiceList()
Loads a list of choices.
public
loadChoiceList([mixed $value = null ]) : ChoiceListInterface
Parameters
- $value : mixed = null
-
The callable which generates the values from choices
Return values
ChoiceListInterface —The loaded choice list
loadChoicesForValues()
Loads the choices corresponding to the given values.
public
loadChoicesForValues(array<string|int, mixed> $values[, mixed $value = null ]) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
-
An array of choice values. Non-existing values in this array are ignored
- $value : mixed = null
-
The callable generating the choice values
Return values
array<string|int, mixed> —An array of choices
loadValuesForChoices()
Loads the values corresponding to the given choices.
public
loadValuesForChoices(array<string|int, mixed> $choices[, mixed $value = null ]) : array<string|int, string>
Parameters
- $choices : array<string|int, mixed>
-
An array of choices. Non-existing choices in this array are ignored
- $value : mixed = null
-
The callable generating the choice values
Return values
array<string|int, string> —An array of choice values