| Conditions | 1 |
| Paths | 1 |
| Total Lines | 11 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public function __invoke(UniqueNameFactory $uniqueNameFactory, ClassMetadata $metadata, QueryBuilder $queryBuilder, string $alias, string $order): void |
||
| 19 | { |
||
| 20 | $queryBuilder->leftJoin($alias . '.institution', 'sortingInstitution'); |
||
| 21 | |||
| 22 | // First keep card without any institution at the bottom of the list |
||
| 23 | $sortingFieldNullAsHighest = $uniqueNameFactory->createAliasName('sorting'); |
||
| 24 | $queryBuilder->addSelect("CASE WHEN sortingInstitution.locality IS NULL OR sortingInstitution.locality = '' THEN 1 ELSE 0 END AS HIDDEN " . $sortingFieldNullAsHighest); |
||
| 25 | $queryBuilder->addOrderBy($sortingFieldNullAsHighest, $order); |
||
| 26 | |||
| 27 | // Then sort cards with institutions |
||
| 28 | $queryBuilder->addOrderBy('sortingInstitution.locality', $order); |
||
| 29 | } |
||
| 31 |