public __construct ( |
||
$em |
public function __construct(EntityManager $em, $class, $property = null, $queryBuilder = null, $choices = array())
{
// If a query builder was passed, it must be a closure or QueryBuilder
// instance
if (!(null === $queryBuilder || $queryBuilder instanceof QueryBuilder || $queryBuilder instanceof \Closure)) {
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder or \Closure');
}
if ($queryBuilder instanceof \Closure) {
$queryBuilder = $queryBuilder($em->getRepository($class));
if (!$queryBuilder instanceof QueryBuilder) {
throw new UnexpectedTypeException($queryBuilder, 'Doctrine\ORM\QueryBuilder');
}
}
$this->em = $em;
$this->class = $class;
$this->queryBuilder = $queryBuilder;
$this->unitOfWork = $em->getUnitOfWork();
$this->identifier = $em->getClassMetadata($class)->getIdentifierFieldNames();
// The property option defines, which property (path) is used for
// displaying entities as strings
if ($property) {
$this->propertyPath = new PropertyPath($property);
}
parent::__construct($choices);
}
/** * Constructs * * @param EntityManager $em * @param string $class * @param string $property * @param QueryBuilder $qb * @param array|\Closure $choices * @param string $groupBy * @param boolean $ajax */ public function __construct(EntityManager $em, $class, $property = null, $qb = null, $choices = null, $groupBy = null, $ajax = false) { $this->ajax = $ajax; if ($property) { $this->propertyPath = new PropertyPath($property); } parent::__construct($em, $class, $property, $qb, $choices, $groupBy); }