Skip to content

Commit

Permalink
Improve parameter checks for Attribute Map dictionaries (CO-2740)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Mar 31, 2025
1 parent 3d7195b commit 48ec051
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/resources/locales/en_US/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ msgstr "Incorrect arguments provided to {0}"
msgid "match.er.attr.req"
msgstr "Required attribute {0} not found in request"

msgid "match.er.attrmap.unknown"
msgstr "Unknown Attribute Map {0}"

msgid "match.er.bl.line"
msgstr "Error at line {0}: {1}"

Expand Down
2 changes: 1 addition & 1 deletion app/src/Controller/AttributeMappingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function install() {

$this->Flash->success(__('match.rs.AttributeMappings.install'));
}
catch(Exception $e) {
catch(\Exception $e) {
$this->Flash->error($e->getMessage());
}

Expand Down
5 changes: 5 additions & 0 deletions app/src/Model/Table/AttributeMappingsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ public function initialize(array $config): void {
*
* @param int $attributeMapId Attribute Map ID to install into
* @param string $mapping Mapping to install, currently only "nicknames.en" is supported
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/

public function install(int $attributeMapId, string $mapping) {
if($mapping != 'nicknames.en') {
throw new \InvalidArgumentException(__('match.er.attrmap.unknown', $mapping));
}

// For now, we assume this is the CSV file from this project:
// https://github.com/carltonnorthern/nickname-and-diminutive-names-lookup
$infile = fopen(ROOT . DS . "vendor" . DS . "nicknames" . DS . "names.csv", "r");
Expand Down

0 comments on commit 48ec051

Please sign in to comment.