Skip to content

Commit

Permalink
Merge pull request #21653 from eileenmcnaughton/ref
Browse files Browse the repository at this point in the history
[REF] stop passing form into createActivities
  • Loading branch information
colemanw authored Sep 28, 2021
2 parents 358dde9 + 2537798 commit 9c8a205
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
17 changes: 8 additions & 9 deletions CRM/Contact/Form/Task/PDFTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ public function addPDFElementsToForm(): void {
ts('Paper Size'),
[0 => ts('- default -')] + CRM_Core_BAO_PaperSize::getList(TRUE),
FALSE,
['onChange' => "selectPaper( this.value ); showUpdateFormatChkBox();"]
['onChange' => 'selectPaper( this.value ); showUpdateFormatChkBox();']
);
$form->add(
'select',
'orientation',
ts('Orientation'),
CRM_Core_BAO_PdfFormat::getPageOrientations(),
FALSE,
['onChange' => "updatePaperDimensions(); showUpdateFormatChkBox();"]
['onChange' => 'updatePaperDimensions(); showUpdateFormatChkBox();']
);
$form->add(
'select',
Expand Down Expand Up @@ -225,13 +225,13 @@ protected function isLiveMode(): bool {
*/
public function postProcess(): void {
$form = $this;
$formValues = $form->controller->exportValues($form->getName());
[$formValues, $html_message, $messageToken, $returnProperties] = $this->processMessageTemplate($formValues);
$formValues = $this->controller->exportValues($this->getName());
[$formValues, $html_message] = $this->processMessageTemplate($formValues);
$html = $activityIds = [];

// CRM-16725 Skip creation of activities if user is previewing their PDF letter(s)
if ($this->isLiveMode()) {
$activityIds = $this->createActivities($form, $html_message, $form->_contactIds, $formValues['subject'], CRM_Utils_Array::value('campaign_id', $formValues));
$activityIds = $this->createActivities($html_message, $form->_contactIds, $formValues['subject'], CRM_Utils_Array::value('campaign_id', $formValues));
}

if (!empty($formValues['document_file_path'])) {
Expand All @@ -257,7 +257,7 @@ public function postProcess(): void {
$tee = NULL;
if ($this->isLiveMode() && Civi::settings()->get('recordGeneratedLetters') === 'combined-attached') {
if (count($activityIds) !== 1) {
throw new CRM_Core_Exception("When recordGeneratedLetters=combined-attached, there should only be one activity.");
throw new CRM_Core_Exception('When recordGeneratedLetters=combined-attached, there should only be one activity.');
}
$tee = CRM_Utils_ConsoleTee::create()->start();
}
Expand Down Expand Up @@ -326,7 +326,6 @@ protected function getMimeType($type) {
}

/**
* @param CRM_Core_Form $form
* @param string $html_message
* @param array $contactIds
* @param string $subject
Expand All @@ -340,8 +339,8 @@ protected function getMimeType($type) {
*
* @throws CRM_Core_Exception
*/
public function createActivities($form, $html_message, $contactIds, $subject, $campaign_id, $perContactHtml = []) {

protected function createActivities($html_message, $contactIds, $subject, $campaign_id, $perContactHtml = []) {
$form = $this;
$activityParams = [
'subject' => $subject,
'campaign_id' => $campaign_id,
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/Task/PDFLetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function postProcess() {
$contactIds = array_keys($contacts);
// CRM-16725 Skip creation of activities if user is previewing their PDF letter(s)
if ($this->isLiveMode()) {
$this->createActivities($this, $html_message, $contactIds, CRM_Utils_Array::value('subject', $formValues, ts('Thank you letter')), CRM_Utils_Array::value('campaign_id', $formValues), $contactHtml);
$this->createActivities($html_message, $contactIds, CRM_Utils_Array::value('subject', $formValues, ts('Thank you letter')), CRM_Utils_Array::value('campaign_id', $formValues), $contactHtml);
}
$html = array_diff_key($html, $emailedHtml);

Expand Down
2 changes: 1 addition & 1 deletion CRM/Member/Form/Task/PDFLetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function postProcessMembers($membershipIDs, $skipOnHold, $skipDeceased, $
$messageToken,
$html_message
);
$form->createActivities($form, $html_message, $contactIDs, $formValues['subject'], CRM_Utils_Array::value('campaign_id', $formValues));
$form->createActivities($html_message, $contactIDs, $formValues['subject'], CRM_Utils_Array::value('campaign_id', $formValues));
CRM_Utils_PDF_Utils::html2pdf($html, $this->getFileName() . '.pdf', FALSE, $formValues);

$form->postProcessHook();
Expand Down

0 comments on commit 9c8a205

Please sign in to comment.