diff --git a/Widget/PersonListWidget.php b/Widget/PersonListWidget.php index b9ef18a4c..f6d8afae7 100644 --- a/Widget/PersonListWidget.php +++ b/Widget/PersonListWidget.php @@ -96,6 +96,8 @@ class PersonListWidget implements WidgetInterface */ public function render(\Twig_Environment $env, $place, array $context, array $config) { + $numberOfItems = $config['number_of_items'] ?? 20; + $qb = $this->personRepository ->createQueryBuilder('person'); @@ -108,7 +110,7 @@ class PersonListWidget implements WidgetInterface // add the "only active" query - if ($config['only_active'] === true) { + if (\array_key_exists('only_active', $config) && $config['only_active'] === true) { $qb->join('person.accompanyingPeriods', 'ap'); $or = new Expr\Orx(); // add the case where closingDate IS NULL @@ -125,7 +127,7 @@ class PersonListWidget implements WidgetInterface } - if ($config['filtering_class'] !== NULL) { + if (\array_key_exists('filtering_class', $config) && $config['filtering_class'] !== NULL) { $filteringClass = new $config['filtering_class']; if ( ! $filteringClass instanceof PersonListWidget\PersonFilteringInterface) { throw new \UnexpectedValueException(sprintf("the class %s does not " @@ -147,7 +149,7 @@ class PersonListWidget implements WidgetInterface ->addOrderBy('person.firstName', 'ASC'); - $qb->setFirstResult(0)->setMaxResults($config['number_of_items']); + $qb->setFirstResult(0)->setMaxResults($numberOfItems); $persons = $qb->getQuery()->getResult();