Skip to content

Commit

Permalink
[REF] dev/core#2790 move preProcess static to the trait
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Aug 31, 2021
1 parent 7420e2e commit 62ddaae
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CRM/Case/Form/Task/PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class CRM_Case_Form_Task_PDF extends CRM_Case_Form_Task {
* Build all the data structures needed to build the form.
*/
public function preProcess() {
CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
$this->preProcessPDF();
$this->skipOnHold = $this->skipDeceased = FALSE;
parent::preProcess();
$this->setContactIDs();
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contact/Form/Task/PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CRM_Contact_Form_Task_PDF extends CRM_Contact_Form_Task {
public function preProcess() {

$this->skipOnHold = $this->skipDeceased = FALSE;
CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
$this->preProcessPDF();

// store case id if present
$this->_caseId = CRM_Utils_Request::retrieve('caseid', 'CommaSeparatedIntegers', $this, FALSE);
Expand Down
1 change: 1 addition & 0 deletions CRM/Contact/Form/Task/PDFLetterCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public static function getLoggingOptions() {
* @param CRM_Core_Form $form
*/
public static function preProcess(&$form) {
CRM_Core_Error::deprecatedFunctionWarning('no alternative');
$defaults = [];
$form->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
if (is_numeric(key($form->_fromEmails))) {
Expand Down
18 changes: 18 additions & 0 deletions CRM/Contact/Form/Task/PDFTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,22 @@ public function addPDFElementsToForm(): void {
$form->addFormRule(['CRM_Core_Form_Task_PDFLetterCommon', 'formRule'], $form);
}

/**
* Prepare form.
*/
public function preProcessPDF(): void {
$form = $this;
$defaults = [];
$form->_fromEmails = CRM_Core_BAO_Email::getFromEmail();
if (is_numeric(key($form->_fromEmails))) {
$emailID = (int) key($form->_fromEmails);
$defaults = CRM_Core_BAO_Email::getEmailSignatureDefaults($emailID);
}
if (!Civi::settings()->get('allow_mail_from_logged_in_contact')) {
$defaults['from_email_address'] = current(CRM_Core_BAO_Domain::getNameAndEmail(FALSE, TRUE));
}
$form->setDefaults($defaults);
$form->setTitle('Print/Merge Document');
}

}
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/Task/PDFLetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CRM_Contribute_Form_Task_PDFLetter extends CRM_Contribute_Form_Task {
*/
public function preProcess() {
$this->skipOnHold = $this->skipDeceased = FALSE;
CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
$this->preProcessPDF();
parent::preProcess();
$this->assign('single', $this->isSingle());
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Event/Form/Task/PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CRM_Event_Form_Task_PDF extends CRM_Event_Form_Task {
* Build all the data structures needed to build the form.
*/
public function preProcess() {
CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
$this->preProcessPDF();
parent::preProcess();

// we have all the participant ids, so now we get the contact ids
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 @@ -43,7 +43,7 @@ public function preProcess() {
$this->skipOnHold = $this->skipDeceased = FALSE;
parent::preProcess();
$this->setContactIDs();
CRM_Contact_Form_Task_PDFLetterCommon::preProcess($this);
$this->preProcessPDF();
}

/**
Expand Down

0 comments on commit 62ddaae

Please sign in to comment.