chg: [enrichment] Defined function to appy inflector on strings

So we can use it each time we want to display the
freetext import / module results status message
pull/4584/head
chrisr3d 2019-04-10 13:13:54 +02:00
parent b47626c970
commit e298f46eef
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 6 additions and 5 deletions

View File

@ -5796,11 +5796,7 @@ class Event extends AppModel
}
}
}
if ($saved == 1) {
$messageScopeSaved = Inflector::singularize($messageScope);
} else {
$messageScopeSaved = Inflector::pluralize($messageScope);
}
$messageScopeSaved = $this-> __apply_inflector($saved, $messageScope);
if ($failed > 0) {
if ($failed == 1) {
$messageScopeFailed = Inflector::singularize($messageScope);
@ -5895,6 +5891,11 @@ class Event extends AppModel
}
}
private function __apply_inflector($count, $scope)
{
return ($count == 1 ? Inflector::singuralize($scope) : Inflector::pluralize($scope));
}
public function processFreeTextDataRouter($user, $attributes, $id, $default_comment = '', $force = false, $adhereToWarninglists = false)
{
if (Configure::read('MISP.background_jobs')) {