Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function getData(Parameters $parameters)
 {
     $orderBy = $this->queryBuilder->orderBy();
     foreach ($this->expressionBuilder->getOrderBys() as $field => $direction) {
         if (is_int($field)) {
             $field = $direction;
             $direction = 'asc';
         }
         // todo: validate direction?
         $direction = strtolower($direction);
         $orderBy->{$direction}()->field(sprintf('%s.%s', Driver::QB_SOURCE_ALIAS, $field));
     }
     $paginator = new Pagerfanta(new DoctrineODMPhpcrAdapter($this->queryBuilder));
     $paginator->setCurrentPage($parameters->get('page', 1));
     return $paginator;
 }
Exemple #2
0
 function it_should_set_the_order_on_the_query_builder_as_fields_only(QueryBuilder $queryBuilder, ExpressionBuilder $expressionBuilder, OrderBy $orderBy, Ordering $ordering)
 {
     $expressionBuilder->getOrderBys()->willReturn(['foo', 'bar']);
     $queryBuilder->orderBy()->willReturn($orderBy);
     $orderBy->asc()->willReturn($ordering);
     $orderBy->asc()->willReturn($ordering);
     $ordering->field('o.foo')->shouldBeCalled();
     $ordering->field('o.bar')->shouldBeCalled();
     $this->getData(new Parameters(['page' => 1]))->shouldHaveType(Pagerfanta::class);
 }