Conversation
Adds note creation for contributions created as SEPA mandates. Moves note creation logic from the Submit API to the Submission class. This change centralizes the creation of contact and contribution notes related to Twingle submissions, promoting code reuse and maintainability. Improves the readability of the Submit API by reducing its complexity. Fixes systopia#96
| /** | ||
| * Create contact notes. | ||
| * | ||
| * @param $contact_id int The contact id. |
There was a problem hiding this comment.
The order of @param is <type hint> <parameter name>.
| * @param $profile CRM_Twingle_Profile The twingle profile used. | ||
| * | ||
| * @return void | ||
| * @throws \CiviCRM_API3_Exception |
There was a problem hiding this comment.
\CiviCRM_API3_Exception is an alias of \CRM_Core_Exception and is going to be removed from CiviCRM core. So this line should be removed.
| * @param $params array The params array from the submission. | ||
| * @param $profile CRM_Twingle_Profile The twingle profile used. | ||
| * | ||
| * @return void |
There was a problem hiding this comment.
This line has no additional information and therefore can be removed.
| /** | ||
| * Create contribution notes. | ||
| * | ||
| * @param $contribution_id int The contribution id. |
There was a problem hiding this comment.
Same as above for the complete comment block.
| * Create contact notes. | ||
| * | ||
| * @param $contact_id int The contact id. | ||
| * @param $params array The params array from the submission. |
There was a problem hiding this comment.
The type hint could be more specific. I assume array<string, mixed>.
| ->execute(); | ||
| } | ||
| } | ||
| CRM_Twingle_Submission::createContactNotes(intval($contact_id), $params, $profile); |
There was a problem hiding this comment.
Type casts to int should be done with (int). However $contact_id should contain an int anyways. Otherwise the assignment should be checked and casted, if necessary. The type is already checked in line 489, though.
| } | ||
|
|
||
| // Add notes to the contribution. | ||
| CRM_Twingle_Submission::createContributionNotes(intval($contribution_id), $params, $profile);; |
There was a problem hiding this comment.
I'd suggest to add the type hint to $contribution_id = $result_values['sepa_mandate']['entity_id']; (line 737) => $contribution_id = (int) $result_values['sepa_mandate']['entity_id'];
| ->execute(); | ||
| } | ||
| } | ||
| CRM_Twingle_Submission::createContributionNotes(intval($contribution['id']), $params, $profile);; |
There was a problem hiding this comment.
Type cast should be done with (int).
SubmitAPI to theCRM_Twingle_Submissionclass.