|
@@ -90,7 +90,7 @@ class EntityChoiceList extends ArrayChoiceList
|
|
|
* @param QueryBuilder|\Closure $queryBuilder An optional query builder
|
|
|
* @param array|\Closure $choices An array of choices or a function returning an array
|
|
|
*/
|
|
|
- public function __construct(EntityManager $em, $class, $property = null, $queryBuilder = null, $choices = array())
|
|
|
+ public function __construct(EntityManager $em, $class, $property = null, $queryBuilder = null, $choices = null)
|
|
|
{
|
|
|
// If a query builder was passed, it must be a closure or QueryBuilder
|
|
|
// instance
|
|
@@ -118,7 +118,11 @@ class EntityChoiceList extends ArrayChoiceList
|
|
|
$this->propertyPath = new PropertyPath($property);
|
|
|
}
|
|
|
|
|
|
- parent::__construct($choices);
|
|
|
+ if (!is_array($choices) && !$choices instanceof \Closure && !is_null($choices)) {
|
|
|
+ throw new UnexpectedTypeException($choices, 'array or \Closure or null');
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->choices = $choices;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -136,7 +140,7 @@ class EntityChoiceList extends ArrayChoiceList
|
|
|
{
|
|
|
parent::load();
|
|
|
|
|
|
- if ($this->choices) {
|
|
|
+ if (is_array($this->choices)) {
|
|
|
$entities = $this->choices;
|
|
|
} else if ($qb = $this->queryBuilder) {
|
|
|
$entities = $qb->getQuery()->execute();
|