W3cubDocs

/Symfony 2.7

Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList

class EntityChoiceList extends ObjectChoiceList

A choice list presenting a list of Doctrine entities as choices

Methods

__construct(ObjectManager $manager, string $class, string $labelPath = null, EntityLoaderInterface $entityLoader = null, array|Traversable|null $entities = null, array $preferredEntities = array(), string $groupPath = null, PropertyAccessorInterface $propertyAccessor = null)

Creates a new entity choice list.

array getChoices()

Returns the list of entities

array getValues()

Returns the values for the entities

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 entities corresponding to the given values.

array getValuesForChoices(array $entities)

Returns the values corresponding to the given entities.

array getIndicesForChoices(array $entities)

Returns the indices corresponding to the given entities.

array getIndicesForValues(array $values)

Returns the entities corresponding to the given values.

Details

public __construct(ObjectManager $manager, string $class, string $labelPath = null, EntityLoaderInterface $entityLoader = null, array|Traversable|null $entities = null, array $preferredEntities = array(), string $groupPath = null, PropertyAccessorInterface $propertyAccessor = null)

Creates a new entity choice list.

Parameters

ObjectManager $manager An EntityManager instance
string $class The class name
string $labelPath The property path used for the label
EntityLoaderInterface $entityLoader An optional query builder
array|Traversable|null $entities An array of choices or null to lazy load
array $preferredEntities An array of preferred choices
string $groupPath A property path pointing to the property used to group the choices. Only allowed if the choices are given as flat array.
PropertyAccessorInterface $propertyAccessor The reflection graph for reading property paths.

public array getChoices()

Returns the list of entities

Return Value

array The choices with their indices as keys

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

public array getValues()

Returns the values for the entities

Return Value

array The values with the corresponding choice indices as keys

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

public array getPreferredViews()

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

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

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

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.

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

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

public array getChoicesForValues(array $values)

Returns the entities corresponding to the given values.

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

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

public array getValuesForChoices(array $entities)

Returns the values corresponding to the given entities.

Parameters

array $entities

Return Value

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

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

public array getIndicesForChoices(array $entities)

Returns the indices corresponding to the given entities.

Parameters

array $entities

Return Value

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

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

public array getIndicesForValues(array $values)

Returns the entities corresponding to the given values.

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

See also

Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.7/Symfony/Bridge/Doctrine/Form/ChoiceList/EntityChoiceList.html