From e298f46eefe4061bb310420a570774076c92b2b0 Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Wed, 10 Apr 2019 13:13:54 +0200 Subject: [PATCH] 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 --- app/Model/Event.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/Model/Event.php b/app/Model/Event.php index 314a28aaf..1a861c089 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -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')) {