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

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

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode Description
load ( ) : array Initializes the choices and returns them

Private Methods

Méthode 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 méthode

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

getEntities() public méthode

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
Résultat array An array of entities

getEntity() public méthode

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)
Résultat object The matching entity

getIdentifier() public méthode

public getIdentifier ( )

getIdentifierValues() public méthode

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 méthode

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
Résultat array An array of choices