From 3b8583de6104e3691603cd2ab07e6b6a2951153b Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 8 Sep 2023 18:49:58 +0900 Subject: [PATCH] Rename ErrorMessage method from setErrorMsgLevel to setError for backend --- src/Logging/ErrorMessage.php | 27 +++++++++++++++++++ .../CoreLibsLoggingErrorMessagesTest.php | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Logging/ErrorMessage.php b/src/Logging/ErrorMessage.php index a7255d3..f705713 100644 --- a/src/Logging/ErrorMessage.php +++ b/src/Logging/ErrorMessage.php @@ -109,6 +109,7 @@ class ErrorMessage * highlight points for field highlights * @param string|null $message If abort/crash, non localized $str * @param array $context Additionl info for abort/crash messages + * @deprecated 9.7 Use setError instead */ public function setErrorMsgLevel( string $level, @@ -122,6 +123,32 @@ class ErrorMessage $this->setErrorMsg($error_id ?? '', $level, $str, $target, $highlight, $message, $context); } + /** + * pushes new error message into the error_str array + * Note, the parameter order is different and does not need an error id + * This is for backend alerts + * + * @param string $level error level (ok/warn/info/error) + * @param string $str error string + * @param string|null $error_id optional error id for precise error lookup + * @param string $target Alternate id name for output target on frontend + * @param array $highlight Any additional error data as error OR + * highlight points for field highlights + * @param string|null $message If abort/crash, non localized $str + * @param array $context Additionl info for abort/crash messages + */ + public function setError( + string $level, + string $str, + ?string $error_id = null, + string $target = '', + array $highlight = [], + ?string $message = null, + array $context = [], + ): void { + $this->setErrorMsg($error_id ?? '', $level, $str, $target, $highlight, $message, $context); + } + // ********************************************************************* // GETTERS // ********************************************************************* diff --git a/test/phpunit/Logging/CoreLibsLoggingErrorMessagesTest.php b/test/phpunit/Logging/CoreLibsLoggingErrorMessagesTest.php index 72012e4..e2b7aea 100644 --- a/test/phpunit/Logging/CoreLibsLoggingErrorMessagesTest.php +++ b/test/phpunit/Logging/CoreLibsLoggingErrorMessagesTest.php @@ -96,7 +96,7 @@ final class CoreLibsLoggingErrorMessagesTest extends TestCase 'log_level' => Level::Debug, ]); $em = new \CoreLibs\Logging\ErrorMessage($log); - $em->setErrorMsgLevel( + $em->setError( $level, $str );