fix query in timeline in activity and person bundle

This commit is contained in:
2021-05-25 09:48:19 +02:00
parent 74541f360b
commit 9b1a66c992
6 changed files with 43 additions and 58 deletions

View File

@@ -28,6 +28,7 @@ use Chill\MainBundle\Entity\Center;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Security\Core\Security;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Chill\MainBundle\Timeline\TimelineSingleQuery;
/**
* Provide method to build timeline for accompanying periods
@@ -88,14 +89,16 @@ abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInt
}
$metadata = $this->em
->getClassMetadata(AccompanyingPeriodParticipation::class)
->getClassMetadata(AccompanyingPeriod::class)
;
return array(
[$where, $parameters] = $this->buildWhereClause($context, $args);
return TimelineSingleQuery::fromArray([
'id' => "{$metadata->getTableName()}.{$metadata->getColumnName('id')}",
'FROM' => $this->buildFromClause($context),
'WHERE' => $this->buildWhereClause($context, $args)
);
'WHERE' => $where,
'parameters' => $parameters
]);
}
private function buildFromClause($context)
@@ -130,9 +133,9 @@ abstract class AbstractTimelineAccompanyingPeriod implements TimelineProviderInt
$join = $participation->getAssociationMapping('person')['joinColumns'][0];
$person = $this->em->getClassMetadata(Person::class);
$joinCenter = $person->getAssociationMapping('center')['joinColumns'][0];
$allowedCenters = $this->authorizationHelper->filterReachableCenters($this->security->getUser(), $args['centers'], PersonVoter::SEE);
if ($context === 'center') {
$allowedCenters = $this->authorizationHelper->filterReachableCenters($this->security->getUser(), $args['centers'], PersonVoter::SEE);
$params = [];
$questionMarks = [];
$query = "{$person->getTableName()}.{$joinCenter['name']} IN (";