Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Complete decommissioning of CRM/Contribute/Form/Task/PDFLetterCommon.php #20172

Merged
merged 1 commit into from
Apr 28, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Apr 27, 2021

Overview

[REF] Complete decommissioning of CRM/Contribute/Form/Task/PDFLetterCommon.php - a class which caused the functionality of CRM/Contribute/Form/Task/PDFLetter to be 'spread' across 2 classes

This removes the last function fromCRM/Contribute/Form/Task/PDFLetterCommon.php, allowing the file to be deleted.

Before

Resolve tokens on CRM/Contribute/Form/Task/PDFLetterCommon.php

After

Resolve tokens on CRM/Contribute/Form/Task/PDFLetter.php , CRM/Contribute/Form/Task/PDFLetterCommon.php deleted

Technical Details

The function was calling a protected function on the parent which had to be unravelled.

I used the method we used in

$str = CRM_Core_BAO_MessageTemplate::renderMessageTemplate(['text' => $str, 'html' => '', 'subject' => ''], TRUE, CRM_Core_Session::getLoggedInContactID(), [])['text'];

to replace the code with the part that we have tested as being done in via render - ie replacing
hook, contact, domain tokens & smarty parsing.

However, there are quite a few tests on this code & one checked that we don't over-call
the token hook. I added some caching for the results of this hook so we can start to
eliminate these but I also allowed the calls to increment by 1 because it is not 1 per row

I made the results of this hook optional to replaceHookTokens & in general I think that
is the only place it needs to be called - perhaps once it used to pass more parameters &
the results were dynamic but now they really aren't

Comments

@seamuslee001 this change is pretty similar to the other you merged, test cover is good

@civibot
Copy link

civibot bot commented Apr 27, 2021

(Standard links)

@civibot civibot bot added the master label Apr 27, 2021
@eileenmcnaughton eileenmcnaughton changed the title [REF] Complete decommissioning on CRM/Contribute/Form/Task/PDFLetterC… [REF] Complete decommissioning on CRM/Contribute/Form/Task/PDFLetterCommon.php Apr 27, 2021
@eileenmcnaughton eileenmcnaughton changed the title [REF] Complete decommissioning on CRM/Contribute/Form/Task/PDFLetterCommon.php [REF] Complete decommissioning of CRM/Contribute/Form/Task/PDFLetterCommon.php Apr 27, 2021
…ommon.php

This removes the last function fromCRM/Contribute/Form/Task/PDFLetterCommon.php

The function was calling a protected function on the parent which had to be unravelled.

I used the method we used in
https://github.com/civicrm/civicrm-core/blob/5e67eb7ff3f1f202d5112d15ad5c6a5f23f35795/CRM/SMS/Form/Upload.php#L341
to replace the code with the part that we have tested as being done in via render - ie replacing
hook, contact, domain tokens & smarty parsing.

However, there are quite a few tests on this code & one checked that we don't over-call
the token hook. I added some caching for the results of this hook so we can start to
eliminate these but I also allowed the calls to increment by 1 because it is not 1 per row

I made the results of this hook optional to replaceHookTokens & in general I think that
is the only place it needs to be called - perhaps once it used to pass more parameters &
the results were dynamic but now they really aren't
@seamuslee001
Copy link
Contributor

This looks fine to me and the test coverage here should be sufficient

@seamuslee001 seamuslee001 merged commit dcccaa7 into civicrm:master Apr 28, 2021
@eileenmcnaughton eileenmcnaughton deleted the pdf branch April 28, 2021 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants