mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
do not throw error when options are missing
This commit is contained in:
parent
b5ad33e521
commit
1afcf75112
@ -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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user