mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fix bug in accompanying period export element
This commit is contained in:
parent
111784410a
commit
4d5900d902
@ -25,3 +25,8 @@ Version 1.5.3
|
||||
- add filtering on accompanying period
|
||||
- fix problems in gender filter
|
||||
|
||||
Version 1.5.4
|
||||
=============
|
||||
|
||||
- Fix bug in accompanying period filter
|
||||
|
||||
|
@ -25,22 +25,34 @@ use Doctrine\ORM\QueryBuilder;
|
||||
*/
|
||||
class AbstractAccompanyingPeriodExportElement
|
||||
{
|
||||
protected function havingAccompanyingPeriodInJoin(QueryBuilder $query)
|
||||
/**
|
||||
* Return true if "accompanying_period" alias is present in the query alises.
|
||||
*
|
||||
* @param QueryBuilder $query
|
||||
* @return bool
|
||||
*/
|
||||
protected function havingAccompanyingPeriodInJoin(QueryBuilder $query): bool
|
||||
{
|
||||
$joins = $query->getDQLPart('join');
|
||||
$joins = $query->getDQLPart('join') ?? [];
|
||||
|
||||
foreach ($joins['person'] as $join) {
|
||||
if ($join->getAlias() === 'accompanying_period') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return (\in_array('accompanying_period', $query->getAllAliases()));
|
||||
}
|
||||
|
||||
protected function addJoinAccompanyingPeriod(QueryBuilder $query)
|
||||
/**
|
||||
* Add the accompanying period alias to the query
|
||||
*
|
||||
* @param QueryBuilder $query
|
||||
* @return void
|
||||
* @throws \LogicException if the "person" alias is not present and attaching accompanying period is not possible
|
||||
*/
|
||||
protected function addJoinAccompanyingPeriod(QueryBuilder $query): void
|
||||
{
|
||||
if (FALSE === $this->havingAccompanyingPeriodInJoin($query)) {
|
||||
if (FALSE === \in_array('person', $query->getAllAliases())) {
|
||||
throw new \LogicException("the alias 'person' does not exists in "
|
||||
. "query builder");
|
||||
}
|
||||
|
||||
$query->join('person.accompanyingPeriods', 'accompanying_period');
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,13 @@ class AccompanyingPeriodFilterTest extends AbstractFilterTest
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
->join('person.accompanyingPeriods', 'accompanying_period')
|
||||
// add a dummy where clause
|
||||
->where('person.firstname IS NOT NULL')
|
||||
->where('person.firstname IS NOT NULL'),
|
||||
$em->createQueryBuilder()
|
||||
->select('activity.date AS date')
|
||||
->select('activity.attendee as attendee')
|
||||
->from("ChillActivityBundle:Activity", 'activity')
|
||||
->join('activity.person', 'person')
|
||||
->join('person.center', 'center')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user