/**
  * Transforms a Specification into a Query
  *
  * @param Specification $specification
  * @return \Doctrine\ORM\Query
  * @throws \InvalidArgumentException
  */
 private function getQuery(Specification $specification)
 {
     if (!$specification->supports($this->getEntityName())) {
         throw new \InvalidArgumentException("Specification does not support this repository");
     }
     $qb = $this->createQueryBuilder('e');
     if ($expr = $specification->match($qb, 'e')) {
         $qb->where($expr);
     }
     $query = $qb->getQuery();
     $specification->modifyQuery($query);
     return $query;
 }
 /**
  * Adds conditions to the query builder related to the specification. The
  * specification should add parameters as required and return the expression to be
  * added to the QueryBuilder.
  *
  * @param \Doctrine\ORM\QueryBuilder $qb
  * @param string $dqlAlias
  * @return \Doctrine\ORM\Query\Expr
  */
 public function match(QueryBuilder $qb, $dqlAlias)
 {
     return $this->specification ? $this->specification->match($qb, $dqlAlias) : null;
 }