/**
  * Evaluates inner joins
  *
  * @param QueryBuilder        $queryBuilder Query builder
  * @param AnnotationPaginator $annotation   Annotation
  *
  * @return PaginatorEvaluatorInterface self Object
  */
 public function evaluate(QueryBuilder $queryBuilder, AnnotationPaginator $annotation)
 {
     if (is_array($annotation->getNotNulls())) {
         foreach ($annotation->getNotNulls() as $notNull) {
             $queryBuilder->andWhere(trim($notNull[0]) . '.' . trim($notNull[1]) . ' IS NOT NULL');
         }
     }
     return $this;
 }
 /**
  * Evaluates inner joins
  *
  * @param QueryBuilder        $queryBuilder Query builder
  * @param AnnotationPaginator $annotation   Annotation
  *
  * @return PaginatorEvaluatorInterface self Object
  */
 public function evaluate(QueryBuilder $queryBuilder, AnnotationPaginator $annotation)
 {
     if (is_array($annotation->getInnerJoins())) {
         foreach ($annotation->getInnerJoins() as $innerJoin) {
             $queryBuilder->innerJoin(trim($innerJoin[0]) . '.' . trim($innerJoin[1]), trim($innerJoin[2]));
             if (isset($innerJoin[3]) && $innerJoin[3]) {
                 $queryBuilder->addSelect(trim($innerJoin[2]));
             }
         }
     }
     return $this;
 }
 /**
  * Evaluates inner joins
  *
  * @param QueryBuilder        $queryBuilder Query builder
  * @param AnnotationPaginator $annotation   Annotation
  *
  * @return PaginatorEvaluatorInterface self Object
  */
 public function evaluate(QueryBuilder $queryBuilder, AnnotationPaginator $annotation)
 {
     if (is_array($annotation->getOrderBy())) {
         foreach ($annotation->getOrderBy() as $orderBy) {
             if (is_array($orderBy)) {
                 $field = $this->requestParameterProvider->getParameterValue(trim($orderBy[1]));
                 $direction = $this->requestParameterProvider->getParameterValue(trim($orderBy[2]), isset($orderBy[3]) && is_array($orderBy[3]) ? $orderBy[3] : null);
                 $queryBuilder->addOrderBy(trim($orderBy[0]) . '.' . $field, $direction);
             }
         }
     }
     return $this;
 }
 /**
  * Evaluates inner joins
  *
  * @param QueryBuilder        $queryBuilder Query builder
  * @param AnnotationPaginator $annotation   Annotation
  *
  * @return PaginatorEvaluatorInterface self Object
  */
 public function evaluate(QueryBuilder $queryBuilder, AnnotationPaginator $annotation)
 {
     $iteration = 0;
     if (is_array($annotation->getWheres())) {
         foreach ($annotation->getWheres() as $where) {
             $annotationWhereParameter = $where[3];
             $whereParameter = $this->clearWildcards($annotationWhereParameter);
             $whereValue = $this->requestParameterProvider->getParameterValue($whereParameter);
             $whereValue = $this->addWildcards($annotationWhereParameter, $whereValue);
             $optionalFilter = (bool) isset($where[4]) ? $where[4] : false;
             if ($optionalFilter && $whereParameter === $whereValue) {
                 continue;
             }
             $queryBuilder->andWhere(trim($where[0]) . '.' . trim($where[1]) . " " . $where[2] . " ?0" . $iteration)->setParameter("0" . $iteration, $whereValue);
             $iteration++;
         }
     }
     return $this;
 }
 /**
  * Evaluates Paginator attributes.
  *
  * @param Request             $request      Request
  * @param AnnotationPaginator $annotation   Annotation
  * @param Paginator           $paginator    Paginator
  * @param integer             $limitPerPage Limit per page
  * @param integer             $page         Page
  */
 protected function evaluateAttributes(Request $request, AnnotationPaginator $annotation, Paginator $paginator, $limitPerPage, $page)
 {
     if ($annotation->getAttributes()) {
         $paginatorAttributes = new PaginatorAttributes();
         $total = $paginator->count();
         $paginatorAttributes->setCurrentPage($page)->setLimitPerPage($limitPerPage)->setTotalElements($total)->setTotalPages(ceil($total / $limitPerPage));
         $request->attributes->set(trim($annotation->getAttributes()), $paginatorAttributes);
     }
 }