From 771fa68c2fbfcfe7a0d0cc4b02bb2f715ed93713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 13 Oct 2016 22:39:56 +0200 Subject: [PATCH] adding an order on person list widget --- Widget/PersonListWidget.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Widget/PersonListWidget.php b/Widget/PersonListWidget.php index 18e55a017..dfebbdc00 100644 --- a/Widget/PersonListWidget.php +++ b/Widget/PersonListWidget.php @@ -110,7 +110,7 @@ class PersonListWidget implements WidgetInterface // add the case where closingDate IS NULL $andWhenClosingDateIsNull = new Expr\Andx(); $andWhenClosingDateIsNull->add((new Expr())->isNull('ap.closingDate')); - $andWhenClosingDateIsNull->add ((new Expr())->gte(':now', 'ap.openingDate')); + $andWhenClosingDateIsNull->add((new Expr())->gte(':now', 'ap.openingDate')); $or->add($andWhenClosingDateIsNull); // add the case when closingDate is in the future $or->add( @@ -138,6 +138,10 @@ class PersonListWidget implements WidgetInterface // adding the where clause to the query $qb->where($and); + // ordering the query by lastname, firstname + $qb->addOrderBy('person.lastName', 'ASC') + ->addOrderBy('person.firstName', 'ASC'); + $qb->setFirstResult(0)->setMaxResults($config['number_of_items']);