From 3fc262b9b74db410f84801a7cbe21982760b23ca Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 24 Apr 2020 12:31:24 +1200 Subject: [PATCH] [REF] Minor extraction Extract the code that renders the generated html it pdfs or word docs --- CRM/Core/Form/Task/PDFLetterCommon.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/CRM/Core/Form/Task/PDFLetterCommon.php b/CRM/Core/Form/Task/PDFLetterCommon.php index e18f05032c..49776534e0 100644 --- a/CRM/Core/Form/Task/PDFLetterCommon.php +++ b/CRM/Core/Form/Task/PDFLetterCommon.php @@ -350,14 +350,7 @@ class CRM_Core_Form_Task_PDFLetterCommon { } if (!empty($html)) { - $type = $formValues['document_type']; - - if ($type === 'pdf') { - CRM_Utils_PDF_Utils::html2pdf($html, "CiviLetter.pdf", FALSE, $formValues); - } - else { - CRM_Utils_PDF_Document::html2doc($html, "CiviLetter.$type", $formValues); - } + self::outputFromHtml($formValues, $html); } } @@ -372,4 +365,19 @@ class CRM_Core_Form_Task_PDFLetterCommon { } } + /** + * Output the pdf or word document from the generated html. + * + * @param array $formValues + * @param array $html + */ + protected static function outputFromHtml($formValues, array $html) { + if ($formValues['document_type'] === 'pdf') { + CRM_Utils_PDF_Utils::html2pdf($html, 'CiviLetter.pdf', FALSE, $formValues); + } + else { + CRM_Utils_PDF_Document::html2doc($html, 'CiviLetter.' . $formValues['document_type'], $formValues); + } + } + } -- 2.25.1