Symfony2 API
Class

Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList

abstract class LazyChoiceList implements ChoiceListInterface

A choice list that is loaded lazily

This list loads itself as soon as any of the getters is accessed for the first time. You should implement loadChoiceList() in your child classes, which should return a ChoiceListInterface instance.

Methods

array getChoices()

Returns the list of choices

array getValues()

Returns the values for the choices

array getPreferredViews()

Returns the choice views of the preferred choices as nested array with the choice groups as top-level keys.

array getRemainingViews()

Returns the choice views of the choices that are not preferred as nested array with the choice groups as top-level keys.

array getChoicesForValues(array $values)

Returns the choices corresponding to the given values.

array getValuesForChoices(array $choices)

Returns the values corresponding to the given choices.

array getIndicesForChoices(array $choices)

Returns the indices corresponding to the given choices.

array getIndicesForValues(array $values)

Returns the indices corresponding to the given values.

Details

at line 37
public array getChoices()

Returns the list of choices

Return Value

array The choices with their indices as keys

at line 49
public array getValues()

Returns the values for the choices

Return Value

array The values with the corresponding choice indices as keys

at line 61
public array getPreferredViews()

Returns the choice views of the preferred choices as nested array with the choice groups as top-level keys.

Example:

array( 'Group 1' => array( 10 => ChoiceView object, 20 => ChoiceView object, ), 'Group 2' => array( 30 => ChoiceView object, ), )

Return Value

array A nested array containing the views with the corresponding choice indices as keys on the lowest levels and the choice group names in the keys of the higher levels

at line 73
public array getRemainingViews()

Returns the choice views of the choices that are not preferred as nested array with the choice groups as top-level keys.

Example:

array( 'Group 1' => array( 10 => ChoiceView object, 20 => ChoiceView object, ), 'Group 2' => array( 30 => ChoiceView object, ), )

Return Value

array A nested array containing the views with the corresponding choice indices as keys on the lowest levels and the choice group names in the keys of the higher levels

at line 85
public array getChoicesForValues(array $values)

Returns the choices corresponding to the given values.

The choices can have any data type.

Parameters

array $values An array of choice values. Not existing values in this array are ignored

Return Value

array An array of choices with ascending, 0-based numeric keys

at line 97
public array getValuesForChoices(array $choices)

Returns the values corresponding to the given choices.

The values must be strings.

Parameters

array $choices An array of choices. Not existing choices in this array are ignored

Return Value

array An array of choice values with ascending, 0-based numeric keys

at line 109
public array getIndicesForChoices(array $choices)

Returns the indices corresponding to the given choices.

The indices must be positive integers or strings accepted by {@link FormConfigBuilder::validateName()}.

The index "placeholder" is internally reserved.

Parameters

array $choices An array of choices. Not existing choices in this array are ignored

Return Value

array An array of indices with ascending, 0-based numeric keys

at line 121
public array getIndicesForValues(array $values)

Returns the indices corresponding to the given values.

The indices must be positive integers or strings accepted by {@link FormConfigBuilder::validateName()}.

The index "placeholder" is internally reserved.

Parameters

array $values An array of choice values. Not existing values in this array are ignored

Return Value

array An array of indices with ascending, 0-based numeric keys