From 4cbce0bae2a434999ecb2c24491ab1824cfa66d1 Mon Sep 17 00:00:00 2001 From: Paul Holden Date: Sun, 24 Sep 2023 18:56:24 +0100 Subject: [PATCH] MDL-79484 tool_mfa: remove hard-coded assumption of "and" lang string. --- .../mfa/classes/local/admin_setting_managemfa.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/admin/tool/mfa/classes/local/admin_setting_managemfa.php b/admin/tool/mfa/classes/local/admin_setting_managemfa.php index 2d7340829005f..af2155e62a15b 100644 --- a/admin/tool/mfa/classes/local/admin_setting_managemfa.php +++ b/admin/tool/mfa/classes/local/admin_setting_managemfa.php @@ -16,6 +16,8 @@ namespace tool_mfa\local; +use tool_mfa\local\factor\object_factor_base; + defined('MOODLE_INTERNAL') || die(); require_once($CFG->libdir.'/ddllib.php'); @@ -200,14 +202,13 @@ public function define_factor_combinations_table() { $table->colclasses = ['leftalign', 'centeralign']; $table->data = []; + $factorstringconnector = get_string('connector', 'tool_mfa'); foreach ($combinations as $combination) { - $string = ''; - foreach ($combination['combination'] as $factor) { - $string .= ' ' . get_string('connector', 'tool_mfa') . ' ' . $factor->get_summary_condition() - . ' ' . $factor->get_weight() . ''; - } + $factorstrings = array_map(static function(object_factor_base $factor): string { + return $factor->get_summary_condition() . ' ' . $factor->get_weight() . ''; + }, $combination['combination']); - $string = substr($string, 4); + $string = implode(" {$factorstringconnector} ", $factorstrings); $table->data[] = new \html_table_row([$string, $combination['totalweight']]); }