From 8e836ab4dcf82317167ffb060140fdb76463a83a Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 19 Apr 2021 15:11:31 +1200 Subject: [PATCH] Remove unused functions These protected functions were extracted as part of the process of testing and transitioning to using the token compatibility subscriber - however, the cleanup of actually removing them once we switched got missed. As they are protected their unusedness is easy to confirm --- CRM/Core/BAO/MessageTemplate.php | 117 ------------------------------- 1 file changed, 117 deletions(-) diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index 44267824cc..ce29dd8aed 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -569,123 +569,6 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { return $mailContent; } - /** - * Get an array of the tokens ito be resolved in the template. - * - * @param array $html - * - * @return array - */ - protected static function getTokensToResolve(array $html): array { - $mailing = new CRM_Mailing_BAO_Mailing(); - $mailing->subject = $html['subject']; - $mailing->body_text = $html['text']; - $mailing->body_html = $html['html']; - return $mailing->getTokens(); - } - - /** - * @param array $mailContent - * @param array $tokens - * @param bool $escapeSmarty - * - * @return array - * @throws \CRM_Core_Exception - */ - protected static function resolveDomainTokens(array $mailContent, array $tokens, bool $escapeSmarty): array { - $domain = CRM_Core_BAO_Domain::getDomain(); - $mailContent['subject'] = CRM_Utils_Token::replaceDomainTokens($mailContent['subject'], $domain, FALSE, $tokens['subject'], $escapeSmarty); - $mailContent['text'] = CRM_Utils_Token::replaceDomainTokens($mailContent['text'], $domain, FALSE, $tokens['text'], $escapeSmarty); - $mailContent['html'] = CRM_Utils_Token::replaceDomainTokens($mailContent['html'], $domain, TRUE, $tokens['html'], $escapeSmarty); - return $mailContent; - } - - /** - * @param $contactID - * @param array|null $tokens - * @param array $mailContent - * @param bool $escapeSmarty - * - * @return array - */ - protected static function resolveContactTokens($contactID, ?array $tokens, array $mailContent, bool $escapeSmarty): array { - $contactParams = ['contact_id' => $contactID]; - $returnProperties = []; - - if (isset($tokens['subject']['contact'])) { - foreach ($tokens['subject']['contact'] as $name) { - $returnProperties[$name] = 1; - } - } - - if (isset($tokens['text']['contact'])) { - foreach ($tokens['text']['contact'] as $name) { - $returnProperties[$name] = 1; - } - } - - if (isset($tokens['html']['contact'])) { - foreach ($tokens['html']['contact'] as $name) { - $returnProperties[$name] = 1; - } - } - - // @todo CRM-17253 don't resolve contact details if there are no tokens - // effectively comment out this next (performance-expensive) line - // but unfortunately testing is a bit think on the ground to that needs to - // be added. - [$contact] = CRM_Utils_Token::getTokenDetails($contactParams, - $returnProperties, - FALSE, FALSE, NULL, - CRM_Utils_Token::flattenTokens($tokens), - // we should consider adding valueName here - 'CRM_Core_BAO_MessageTemplate' - ); - $contact = $contact[$contactID]; - $mailContent['subject'] = CRM_Utils_Token::replaceContactTokens($mailContent['subject'], $contact, FALSE, $tokens['subject'], FALSE, $escapeSmarty); - $mailContent['text'] = CRM_Utils_Token::replaceContactTokens($mailContent['text'], $contact, FALSE, $tokens['text'], FALSE, $escapeSmarty); - $mailContent['html'] = CRM_Utils_Token::replaceContactTokens($mailContent['html'], $contact, FALSE, $tokens['html'], FALSE, $escapeSmarty); - - $contactArray = [$contactID => $contact]; - CRM_Utils_Hook::tokenValues($contactArray, - [$contactID], - NULL, - CRM_Utils_Token::flattenTokens($tokens), - // we should consider adding valueName here - 'CRM_Core_BAO_MessageTemplate' - ); - $contact = $contactArray[$contactID]; - - $hookTokens = []; - CRM_Utils_Hook::tokens($hookTokens); - $categories = array_keys($hookTokens); - $mailContent['subject'] = CRM_Utils_Token::replaceHookTokens($mailContent['subject'], $contact, $categories, TRUE); - $mailContent['text'] = CRM_Utils_Token::replaceHookTokens($mailContent['text'], $contact, $categories, TRUE); - $mailContent['html'] = CRM_Utils_Token::replaceHookTokens($mailContent['html'], $contact, $categories, TRUE); - return $mailContent; - } - - /** - * @param array $mailContent - * @param $tplParams - * - * @return array - */ - protected static function parseThroughSmarty(array $mailContent, $tplParams): array { - // strip whitespace from ends and turn into a single line - $mailContent['subject'] = "{strip}{$mailContent['subject']}{/strip}"; - - // parse the three elements with Smarty - $smarty = CRM_Core_Smarty::singleton(); - foreach ($tplParams as $name => $value) { - $smarty->assign($name, $value); - } - foreach (['subject', 'text', 'html'] as $elem) { - $mailContent[$elem] = $smarty->fetch("string:{$mailContent[$elem]}"); - } - return $mailContent; - } - /** * Render the message template, resolving tokens and smarty tokens. * -- 2.25.1