Skip to content

Commit

Permalink
Merge pull request #6665 from ChurchCRM/fix-adding-group-roles
Browse files Browse the repository at this point in the history
fix adding group roles by properly retrieving required service from the container
  • Loading branch information
DawoudIO authored Nov 14, 2023
2 parents 49021c9 + a733144 commit 5342167
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
14 changes: 10 additions & 4 deletions src/api/routes/finance/finance-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
$app->post('/', function ($request, $response, $args) {
$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) {
Expand All @@ -33,7 +40,6 @@
$data = $query->find();

$rows = [];

foreach ($data as $row) {
$newRow['FormattedFY'] = $row->getFormattedFY();
$newRow['GroupKey'] = $row->getGroupKey();
Expand Down
20 changes: 13 additions & 7 deletions src/api/routes/people/people-groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,20 @@
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'];
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) {
$app->post('/{groupID:[0-9]+}/roles', function ($request, $response, $args) {
$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) {
Expand All @@ -225,14 +229,16 @@
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');

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']);
}
});
Expand Down

0 comments on commit 5342167

Please sign in to comment.