diff --git a/app/resources/locales/en_US/default.po b/app/resources/locales/en_US/default.po index 4893d51d..4caee09a 100644 --- a/app/resources/locales/en_US/default.po +++ b/app/resources/locales/en_US/default.po @@ -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}" diff --git a/app/src/Controller/AttributeMappingsController.php b/app/src/Controller/AttributeMappingsController.php index 65eda7c6..4cbd9ce9 100644 --- a/app/src/Controller/AttributeMappingsController.php +++ b/app/src/Controller/AttributeMappingsController.php @@ -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()); } diff --git a/app/src/Model/Table/AttributeMappingsTable.php b/app/src/Model/Table/AttributeMappingsTable.php index 26c85f8f..ccb31867 100644 --- a/app/src/Model/Table/AttributeMappingsTable.php +++ b/app/src/Model/Table/AttributeMappingsTable.php @@ -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");