Skip to content

Commit

Permalink
Merge pull request #18441 from eileenmcnaughton/5.29
Browse files Browse the repository at this point in the history
APIv4 - Map specific action names to more generic versions
  • Loading branch information
colemanw authored Sep 12, 2020
2 parents f4570b6 + d018779 commit c78bd17
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Civi/Api4/Generic/AbstractAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,13 +407,15 @@ public function getPermissions() {
'default' => ['administer CiviCRM'],
];
$action = $this->getActionName();
if (isset($permissions[$action])) {
return $permissions[$action];
}
elseif (in_array($action, ['getActions', 'getFields'])) {
return $permissions['meta'];
}
return $permissions['default'];
// Map specific action names to more generic versions
$map = [
'getActions' => 'meta',
'getFields' => 'meta',
'replace' => 'delete',
'save' => 'create',
];
$generic = $map[$action] ?? 'default';
return $permissions[$action] ?? $permissions[$generic] ?? $permissions['default'];
}

/**
Expand Down

0 comments on commit c78bd17

Please sign in to comment.