From 81756b44101bd5f24bba8b285c2b1d382d6c6135 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 18 Nov 2015 17:24:24 -0500 Subject: [PATCH] CRM-13823 - Extract setLevel method from CRM_Utils_Check_Message constructor --- CRM/Utils/Check/Env.php | 2 +- CRM/Utils/Check/Message.php | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CRM/Utils/Check/Env.php b/CRM/Utils/Check/Env.php index bae90c47df..6b86338207 100644 --- a/CRM/Utils/Check/Env.php +++ b/CRM/Utils/Check/Env.php @@ -508,7 +508,7 @@ class CRM_Utils_Check_Env { return array(new CRM_Utils_Check_Message( 'extensionsOk', ts('No extensions installed. Browse available extensions.', array( - 1 => CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1'), + 1 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', 'reset=1') . '"', )), ts('Extensions'), \Psr\Log\LogLevel::INFO, diff --git a/CRM/Utils/Check/Message.php b/CRM/Utils/Check/Message.php index 827613da60..adf05e9530 100644 --- a/CRM/Utils/Check/Message.php +++ b/CRM/Utils/Check/Message.php @@ -96,16 +96,8 @@ class CRM_Utils_Check_Message { $this->name = $name; $this->message = $message; $this->title = $title; - // Convert level to integer - if (!CRM_Utils_Rule::positiveInteger($level)) { - $level = CRM_Utils_Check::severityMap($level); - } - else { - // Validate numeric input - this will throw an exception if invalid - CRM_Utils_Check::severityMap($level, TRUE); - } - $this->level = $level; $this->icon = $icon; + $this->setLevel($level); } /** @@ -162,6 +154,26 @@ class CRM_Utils_Check_Message { $this->help = $help; } + /** + * Set severity level + * + * @param string|int $level + * @throws \CRM_Core_Exception + */ + public function setLevel($level) { + // Convert level to integer + if (!CRM_Utils_Rule::positiveInteger($level)) { + $level = CRM_Utils_Check::severityMap($level); + } + else { + // Validate numeric input - this will throw an exception if invalid + CRM_Utils_Check::severityMap($level, TRUE); + } + $this->level = $level; + // Clear internal caches + unset($this->isVisible, $this->hiddenUntil); + } + /** * Convert to array. * -- 2.25.1