PHP Class Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList

Inheritance: extends Symfony\Component\Form\Extension\Core\ChoiceList\ArrayChoiceList
Show file Open project: pmjones/php-framework-benchmarks Class Usage Examples

Public Methods

Method Description
__construct ( EntityManager $em, $class, $property = null, $queryBuilder = null, $choices = [] )
getEntities ( ) : array Returns the according entities for the choices
getEntity ( string $key ) : object Returns the entity for the given key
getIdentifier ( )
getIdentifierValues ( object $entity ) Returns the values of the identifier fields of an entity

Protected Methods

Method Description
load ( ) : array Initializes the choices and returns them

Private Methods

Method Description
getReflProperty ( string $property ) : ReflectionProperty Returns the \ReflectionProperty instance for a property of the underlying class
loadEntities ( $entities, $group = null ) Convert entities into choices with support for groups

Method Details

__construct() public method

public __construct ( EntityManager $em, $class, $property = null, $queryBuilder = null, $choices = [] )
$em Doctrine\ORM\EntityManager

getEntities() public method

If the choices were not initialized, they are initialized now. This is an expensive operation, except if the entities were passed in the "choices" option.
public getEntities ( ) : array
return array An array of entities

getEntity() public method

If the underlying entities have composite identifiers, the choices are initialized. The key is expected to be the index in the choices array in this case. If they have single identifiers, they are either fetched from the internal entity cache (if filled) or loaded from the database.
public getEntity ( string $key ) : object
$key string The choice key (for entities with composite identifiers) or entity ID (for entities with single identifiers)
return object The matching entity

getIdentifier() public method

public getIdentifier ( )

getIdentifierValues() public method

Doctrine must know about this entity, that is, the entity must already be persisted or added to the identity map before. Otherwise an exception is thrown.
public getIdentifierValues ( object $entity )
$entity object The entity for which to get the identifier

load() protected method

If the entities were passed in the "choices" option, this method does not have any significant overhead. Otherwise, if a query builder was passed in the "query_builder" option, this builder is now used to construct a query which is executed. In the last case, all entities for the underlying class are fetched from the repository.
protected load ( ) : array
return array An array of choices