fix: Fix bug reported by the tests.

This commit is contained in:
Pol Dellaiera 2021-11-18 12:17:04 +01:00
parent c1a4454a08
commit 11ad94ee09
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA

View File

@ -87,8 +87,7 @@ class TimelineReportProvider implements TimelineProviderInterface
$report = $this->em->getClassMetadata(Report::class);
$person = $this->em->getClassMetadata(Person::class);
$role = new Role('CHILL_REPORT_SEE');
$reachableCenters = $this->helper->getReachableCenters($this->security->getUser(),
$role);
$reachableCenters = $this->helper->getReachableCenters($this->security->getUser(), $role->getRole());
$reportPersonId = $report->getAssociationMapping('person')['joinColumns'][0]['name'];
$reportScopeId = $report->getAssociationMapping('scope')['joinColumns'][0]['name'];
$personCenterId = $person->getAssociationMapping('center')['joinColumns'][0]['name'];
@ -111,8 +110,7 @@ class TimelineReportProvider implements TimelineProviderInterface
$parameters[] = $center->getId();
// loop over scopes
$scopeIds = [];
foreach ($this->helper->getReachableScopes($this->security->getUser(),
$role, $center) as $scope) {
foreach ($this->helper->getReachableScopes($this->security->getUser(), $role->getRole(), $center) as $scope) {
if (\in_array($scope->getId(), $scopeIds)) {
continue;
}
@ -158,8 +156,7 @@ class TimelineReportProvider implements TimelineProviderInterface
// this is the final clause that we are going to fill
$clause = "{report}.{person_id} = ? AND {report}.{scopes_id} IN ({scopes_ids})";
// iterate over reachable scopes
$scopes = $this->helper->getReachableScopes($this->security->getUser(), $role,
$args['person']->getCenter());
$scopes = $this->helper->getReachableScopes($this->security->getUser(), $role->getRole(), $args['person']->getCenter());
foreach ($scopes as $scope) {
if (\in_array($scope->getId(), $parameters)) {