From 7fd45d57358ce7ceca95832c4caf2b1a616e043d Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Thu, 18 Nov 2021 14:33:06 +0100 Subject: [PATCH] fix: Remove deprecations. --- .../Timeline/TimelineReportProvider.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php index 448232e4f..04f4ba346 100644 --- a/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php +++ b/src/Bundle/ChillReportBundle/Timeline/TimelineReportProvider.php @@ -22,7 +22,6 @@ use Chill\MainBundle\Timeline\TimelineSingleQuery; */ class TimelineReportProvider implements TimelineProviderInterface { - protected EntityManager $em; protected AuthorizationHelper $helper; @@ -84,10 +83,12 @@ class TimelineReportProvider implements TimelineProviderInterface private function getWhereClauseForCenter(string $context, array $args): array { + $role = 'CHILL_REPORT_SEE'; + $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->getRole()); + + $reachableCenters = $this->helper->getReachableCenters($this->security->getUser(), $role); $reportPersonId = $report->getAssociationMapping('person')['joinColumns'][0]['name']; $reportScopeId = $report->getAssociationMapping('scope')['joinColumns'][0]['name']; $personCenterId = $person->getAssociationMapping('center')['joinColumns'][0]['name']; @@ -110,7 +111,7 @@ class TimelineReportProvider implements TimelineProviderInterface $parameters[] = $center->getId(); // loop over scopes $scopeIds = []; - foreach ($this->helper->getReachableScopes($this->security->getUser(), $role->getRole(), $center) as $scope) { + foreach ($this->helper->getReachableScopes($this->security->getUser(), $role, $center) as $scope) { if (\in_array($scope->getId(), $scopeIds)) { continue; } @@ -144,9 +145,9 @@ class TimelineReportProvider implements TimelineProviderInterface private function getWhereClauseForPerson(string $context, array $args): array { + $role = 'CHILL_REPORT_SEE'; $report = $this->em->getClassMetadata(Report::class); $person = $this->em->getClassMetadata(Person::class); - $role = new Role('CHILL_REPORT_SEE'); $reportPersonId = $report->getAssociationMapping('person')['joinColumns'][0]['name']; $reportScopeId = $report->getAssociationMapping('scope')['joinColumns'][0]['name']; $personCenterId = $person->getAssociationMapping('center')['joinColumns'][0]['name']; @@ -156,7 +157,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->getRole(), $args['person']->getCenter()); + $scopes = $this->helper->getReachableScopes($this->security->getUser(), $role, $args['person']->getCenter()); foreach ($scopes as $scope) { if (\in_array($scope->getId(), $parameters)) {