From 0d0db46035942584b28b074d571ca76d5b873d21 Mon Sep 17 00:00:00 2001 From: Arun Philip Date: Mon, 13 Nov 2023 19:17:21 -0500 Subject: [PATCH 1/2] fix adding group roles by properly retrieving required service from the container --- src/api/routes/finance/finance-payments.php | 12 +++++++++--- src/api/routes/people/people-groups.php | 14 ++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/api/routes/finance/finance-payments.php b/src/api/routes/finance/finance-payments.php index 82eef9bde5..3eb3e45e8f 100644 --- a/src/api/routes/finance/finance-payments.php +++ b/src/api/routes/finance/finance-payments.php @@ -9,12 +9,19 @@ $app->group('/payments', function () use ($app) { $app->get('/', function (Request $request, Response $response, array $args) use ($app) { - $app->FinancialService->getPaymentJSON($app->FinancialService->getPayments()); + $financialService = $this->get('FinancialService'); + + echo $financialService->getPaymentJSON($app->FinancialService->getPayments()); }); $app->post('/', function ($request, $response, $args) use ($app) { $payment = $request->getParsedBody(); - echo json_encode(['payment' => $app->FinancialService->submitPledgeOrPayment($payment)], JSON_THROW_ON_ERROR); + $financialService = $this->get('FinancialService'); + + echo json_encode( + ['payment' => $financialService->submitPledgeOrPayment($payment)], + JSON_THROW_ON_ERROR + ); }); $app->get('/family/{familyId:[0-9]+}/list', function (Request $request, Response $response, array $args) { @@ -33,7 +40,6 @@ $data = $query->find(); $rows = []; - foreach ($data as $row) { $newRow['FormattedFY'] = $row->getFormattedFY(); $newRow['GroupKey'] = $row->getGroupKey(); diff --git a/src/api/routes/people/people-groups.php b/src/api/routes/people/people-groups.php index 4f53c68e69..44230641a7 100644 --- a/src/api/routes/people/people-groups.php +++ b/src/api/routes/people/people-groups.php @@ -207,13 +207,17 @@ $app->delete('/{groupID:[0-9]+}/roles/{roleID:[0-9]+}', function ($request, $response, $args) use ($app) { $groupID = $args['groupID']; $roleID = $args['roleID']; - echo json_encode($app->GroupService->deleteGroupRole($groupID, $roleID), JSON_THROW_ON_ERROR); + $groupService = $this->get('GroupService'); + + echo json_encode($groupService->deleteGroupRole($groupID, $roleID), JSON_THROW_ON_ERROR); }); $app->post('/{groupID:[0-9]+}/roles', function ($request, $response, $args) use ($app) { $groupID = $args['groupID']; $roleName = $request->getParsedBody()['roleName']; - echo $app->GroupService->addGroupRole($groupID, $roleName); + $groupService = $this->get('GroupService'); + + echo $groupService->addGroupRole($groupID, $roleName); }); $app->post('/{groupID:[0-9]+}/defaultRole', function ($request, $response, $args) { @@ -228,11 +232,13 @@ $app->post('/{groupID:[0-9]+}/setGroupSpecificPropertyStatus', function ($request, $response, $args) use ($app) { $groupID = $args['groupID']; $input = $request->getParsedBody(); + $groupService = $this->get('GroupService'); + if ($input['GroupSpecificPropertyStatus']) { - $app->GroupService->enableGroupSpecificProperties($groupID); + $groupService->enableGroupSpecificProperties($groupID); echo json_encode(['status' => 'group specific properties enabled']); } else { - $app->GroupService->disableGroupSpecificProperties($groupID); + $groupService->disableGroupSpecificProperties($groupID); echo json_encode(['status' => 'group specific properties disabled']); } }); From 1bc947f9923411c8e563358662de35fd23d23f92 Mon Sep 17 00:00:00 2001 From: Arun Philip Date: Tue, 14 Nov 2023 00:17:35 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/api/routes/finance/finance-payments.php | 2 +- src/api/routes/people/people-groups.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api/routes/finance/finance-payments.php b/src/api/routes/finance/finance-payments.php index 3eb3e45e8f..30f99a8dca 100644 --- a/src/api/routes/finance/finance-payments.php +++ b/src/api/routes/finance/finance-payments.php @@ -14,7 +14,7 @@ echo $financialService->getPaymentJSON($app->FinancialService->getPayments()); }); - $app->post('/', function ($request, $response, $args) use ($app) { + $app->post('/', function ($request, $response, $args) { $payment = $request->getParsedBody(); $financialService = $this->get('FinancialService'); diff --git a/src/api/routes/people/people-groups.php b/src/api/routes/people/people-groups.php index 44230641a7..ab830ba178 100644 --- a/src/api/routes/people/people-groups.php +++ b/src/api/routes/people/people-groups.php @@ -204,7 +204,7 @@ echo json_encode(['success' => false]); }); - $app->delete('/{groupID:[0-9]+}/roles/{roleID:[0-9]+}', function ($request, $response, $args) use ($app) { + $app->delete('/{groupID:[0-9]+}/roles/{roleID:[0-9]+}', function ($request, $response, $args) { $groupID = $args['groupID']; $roleID = $args['roleID']; $groupService = $this->get('GroupService'); @@ -212,7 +212,7 @@ echo json_encode($groupService->deleteGroupRole($groupID, $roleID), JSON_THROW_ON_ERROR); }); - $app->post('/{groupID:[0-9]+}/roles', function ($request, $response, $args) use ($app) { + $app->post('/{groupID:[0-9]+}/roles', function ($request, $response, $args) { $groupID = $args['groupID']; $roleName = $request->getParsedBody()['roleName']; $groupService = $this->get('GroupService'); @@ -229,7 +229,7 @@ echo json_encode(['success' => true]); }); - $app->post('/{groupID:[0-9]+}/setGroupSpecificPropertyStatus', function ($request, $response, $args) use ($app) { + $app->post('/{groupID:[0-9]+}/setGroupSpecificPropertyStatus', function ($request, $response, $args) { $groupID = $args['groupID']; $input = $request->getParsedBody(); $groupService = $this->get('GroupService');