From a7ba6e074072c41b9172903dc2006d8435240603 Mon Sep 17 00:00:00 2001 From: rowan04 Date: Tue, 12 Sep 2023 15:02:38 +0000 Subject: [PATCH] Code formatting fixes - as suggested by codeclimate and codacy --- lib/Doctrine/deploy/AddServiceGroupRoles.php | 43 +++++++++++-------- .../deploy/DeploySampleDataRunner.php | 2 +- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/lib/Doctrine/deploy/AddServiceGroupRoles.php b/lib/Doctrine/deploy/AddServiceGroupRoles.php index dd294a8c8..9e3f51091 100644 --- a/lib/Doctrine/deploy/AddServiceGroupRoles.php +++ b/lib/Doctrine/deploy/AddServiceGroupRoles.php @@ -1,15 +1,16 @@ USER_ROLE as $role) { +foreach ($usersRoles as $user) { + foreach ($user->USER_ROLE as $role) { // Check for blank role, skip if it's blank - if((string) $role->USER_ROLE == "") { + if ((string) $role->USER_ROLE == "") { continue; } @@ -29,18 +30,19 @@ * Error checking: ensure each role type refers to exactly * one role type */ - if(count($roleTypes) !== 1) { - throw new Exception(count($roleTypes) . " role types found with name: " . - $userRole); + if (count($roleTypes) !== 1) { + throw new Exception(count($roleTypes) . " role types " . + "found with name: " . $userRole); } - foreach($roleTypes as $result) { + foreach ($roleTypes as $result) { $roleType = $result; } // Get user entity $userDN = (string) $user->CERTDN; - $dql = "SELECT u FROM User u JOIN u.userIdentifiers up WHERE up.keyValue = :keyValue"; + $dql = "SELECT u FROM User u JOIN u.userIdentifiers up " . + "WHERE up.keyValue = :keyValue"; $users = $entityManager->createQuery($dql) ->setParameter('keyValue', trim($userDN)) ->getResult(); @@ -49,12 +51,12 @@ * Error checking: ensure each "user" refers to exactly * one user */ - if(count($users) !== 1) { + if (count($users) !== 1) { throw new Exception(count($users) . " users found with DN: " . $userDN); } - foreach($users as $doctrineUser) { + foreach ($users as $doctrineUser) { $doctrineUser = $doctrineUser; } @@ -69,16 +71,21 @@ * Error checking: ensure each "service group" refers to exactly * one service group */ - if(count($serviceGroups) !== 1) { - throw new Exception(count($serviceGroups) . " Service Groups found name: " . - $sgName); + if (count($serviceGroups) !== 1) { + throw new Exception(count($serviceGroups) . " Service Groups " . + "found name: " . $sgName); } - foreach($serviceGroups as $serviceGroup) { + foreach ($serviceGroups as $serviceGroup) { $serviceGroup = $serviceGroup; } - $doctrineRole = new Role($roleType, $doctrineUser, $serviceGroup, 'STATUS_GRANTED'); + $doctrineRole = new Role( + $roleType, + $doctrineUser, + $serviceGroup, + 'STATUS_GRANTED' + ); $entityManager->persist($doctrineRole); } } diff --git a/lib/Doctrine/deploy/DeploySampleDataRunner.php b/lib/Doctrine/deploy/DeploySampleDataRunner.php index 217f1bff8..48f8a60e5 100644 --- a/lib/Doctrine/deploy/DeploySampleDataRunner.php +++ b/lib/Doctrine/deploy/DeploySampleDataRunner.php @@ -54,5 +54,5 @@ require __DIR__."/AddProjectRoles.php"; echo "Added EGI level Roles OK\n"; -require __DIR__."/AddServiceGroupRoles.php"; +require __DIR__ . "/AddServiceGroupRoles.php"; echo "Added Service Group level Roles OK\n";