Added count to alias editor import

This commit is contained in:
Matthew Barbour 2020-03-02 15:21:27 +00:00 committed by Shish
parent 8ff52b9220
commit ba599d5d1b

View file

@ -177,19 +177,22 @@ class AliasEditor extends Extension
return $csv; return $csv;
} }
private function add_alias_csv(Database $database, string $csv) private function add_alias_csv(Database $database, string $csv): int
{ {
$csv = str_replace("\r", "\n", $csv); $csv = str_replace("\r", "\n", $csv);
$i = 0;
foreach (explode("\n", $csv) as $line) { foreach (explode("\n", $csv) as $line) {
$parts = str_getcsv($line); $parts = str_getcsv($line);
if (count($parts) == 2) { if (count($parts) == 2) {
try { try {
send_event(new AddAliasEvent($parts[0], $parts[1])); send_event(new AddAliasEvent($parts[0], $parts[1]));
$i++;
} catch (AddAliasException $ex) { } catch (AddAliasException $ex) {
$this->theme->display_error(500, "Error adding alias", $ex->getMessage()); $this->theme->display_error(500, "Error adding alias", $ex->getMessage());
} }
} }
} }
return $i;
} }
/** /**