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

dev/core#2832 Add test for legacy membership tokens, add support for preferred tokens #21453

Merged
merged 1 commit into from
Sep 13, 2021

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Sep 13, 2021

Overview

dev/core#2832 Add test for legacy membership tokens, add support for preferred tokens

Before

Less tests, more code, no support for preferred unambiguous tokens {membership.status_id:label} & {membership.membership_type_id:labe}

After

This is mostly about adding the tests to permit changing to the processor & ensuring no unexpected changes.

However, I've fixed the outgoing code to support the preferred unambiguous tokens.

It seems like a little extra work now but it means that we will know those tokens work consistently, even from (unsupported) outside of core calls. Also it means that if the full conversion gets too hard the existing code supports these preferred tokens

Working through that also allowed me to rdetermine the complicated code wasn't achieving anything a fixed array didn't and switching to a fixed array removed a dependency from the outgoing code to other core code.

Technical Details

There is only one place that calls this code. With cover of the legacy tokens
I can ensure it is the same as the processor tokens.

Comments

…preferred tokens

There is only one place that calls this code. With cover of the legacy tokens
I can ensure it is the same as the processor tokens. I've fixed it
to support the preferred unambiguous tokens because that means that
we don't have to deal with reports of them not working while calls
to it are phased out of extensions. Working through that
also allowed me to remove some code now
@civibot
Copy link

civibot bot commented Sep 13, 2021

(Standard links)

@civibot civibot bot added the master label Sep 13, 2021
* Store membership tokens on the static _tokens array.
*/
protected static function _buildMembershipTokens() {
$key = 'membership';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced with a fixed array

@@ -1714,13 +1707,29 @@ public static function replaceMultipleContributionTokens(string $separator, stri
* @return string token replacement
*/
public static function getMembershipTokenReplacement($entity, $token, $membership) {
self::_buildMembershipTokens();
$supportedTokens = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@seamuslee001 seamuslee001 merged commit 94dcc53 into civicrm:master Sep 13, 2021
@seamuslee001 seamuslee001 deleted the member_tokens branch September 13, 2021 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants