switch to token processor
This switchs pdf->create and pdf->sendPdf to use the new TokenProcessor. The idea was copied from the change from email api emailapi!43 (merged)
I have tested together with civicrm 5.43 / 5.54 and CiviRules. We use this Tokens: contact (core and custom), event (core and custom), participiant (core and custom).
Not tested: Case and Contribution Tokens and Multiply contacts
Merge request reports
Activity
mentioned in issue #31 (closed)
Thanks for the merge request @david124136468769 There are a lot of changes in here which do not relate to "switch to token processor" - would you be able to separate these out into separate merge requests or at least provide some explanation for the other changes?
@jaapjansma would you mind reviewing? And this extension could probably do with a new tag and release, there are other merged changes which have not been released.
mentioned in issue dev/core#4128 (closed)
115 116 if (isset($this->_apiParams['case_id']) && !empty($this->_apiParams['case_id'])) { 117 $schema[] = 'caseId'; 118 $context['caseId'] = $this->_apiParams['case_id']; 119 120 //CRM-4524 121 // Hack for Case Token Extension 122 \Civi::$statics['casetokens']['case_id'] = $this->_apiParams['case_id']; 123 } 124 elseif (isset($this->_apiParams['extra_data']['case']) && !empty($this->_apiParams['extra_data']['case'])) { 125 $schema[] = 'caseId'; 126 $context['caseId'] = $this->_apiParams['extra_data']['case']['id']; 116 127 } 117 128 118 $html = []; 129 foreach ($this->_apiParams['extra_data'] as $entity => $entityData) { 135 'sort_name' => 1, 136 'email' => 1, 137 'address' => 1, 138 'do_not_email' => 1, 139 'is_deceased' => 1, 140 'on_hold' => 1, 141 'display_name' => 1, 142 ]; 143 if (is_array($messageTokens['contact'])) { 144 foreach ($messageTokens['contact'] as $prop) { 145 $returnProperties[$prop] = 1; 151 $this->_htmlMessage = $this->formatMessage($messageTemplate); 152 153 $filterdIds = []; 154 // search for contacts which should not resive a mail 155 $filterdContacts = \Civi\Api4\Contact::get() I think this is the biggest change. Here the logic is reversed. Old: first get all token values and then check if it is a valid mail. New: get invalid mail and then get token values.
I am not trying (and don't know) if it is possible to use the token processor first and then sort so the logic would be the same.
@justinfreeman I add some comments and hope this is helpful.
Awesome thanks @david124136468769 for taking the time to explain those changes.
PR works for us.
@jaapjansma review required mate.
This patch will be tested by someone from CiviService. After they have tested it I will merge it and create a new release.
@justinfreeman do you have anything particular you want me to review?
mentioned in commit 508fe2ff