fix: Remove deprecations.

This commit is contained in:
Pol Dellaiera 2021-11-18 14:33:06 +01:00
parent ae79ebc299
commit 7fd45d5735
No known key found for this signature in database
GPG Key ID: D476DFE9C67467CA

View File

@ -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)) {