From 94a7c422891aa90065754b520734d38304c32bf4 Mon Sep 17 00:00:00 2001 From: Philipp Dieter Date: Thu, 24 Mar 2022 18:06:06 +0100 Subject: [PATCH] [TASK] MailUtility: Add function extractByType --- Classes/Utility/MailUtility.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Classes/Utility/MailUtility.php b/Classes/Utility/MailUtility.php index dbc2c12..d90a5d1 100644 --- a/Classes/Utility/MailUtility.php +++ b/Classes/Utility/MailUtility.php @@ -128,6 +128,28 @@ class MailUtility return $result; } + /** + * Gets row from content by given type + * + * @param array $content the mail content + * @param string $type the type to search + */ + public static function extractByType($content, $type) + { + $elementPosition = array_search( + $type, + array_column($content, 'type') + ); + if (!$elementPosition === false) { + return; + } + if (!array_key_exists('data', $content[$elementPosition])) { + return; + } + return $content[$elementPosition]['data']; + } + + /** * tages maildata, builds html and text mails an decides where to send them * allows to intercept sender for testing