mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-02 21:13:57 +00:00
Fix bug in accompanying period export element
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user