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

Function extraction (Move towards generic custom data support for all entities) #12095

Merged
merged 1 commit into from
May 8, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Basic code clean up

(reviewer's commit from 28bbc8d)

Before

Code not re-usable

After

Code re-usable

Technical Details

@mattwire this is a review commit of your patch here
28bbc8d

In general I think your patch makes sense as an extraction & I thought it worth splitting this part off & getting it merged so we could build on it. I still have thoughts about whether this is the best place for the extracted function (back to our traits experiments) but I think a refactoring can have several steps & this is a step in the right direction.

Changes I made from yours

  1. I left off the change in utils.php as I didn't know the reason
  2. comments changes
  3. This is the significant one - I changed the order of the params in addToForm as
    a) they didn't seem to match what was being passed in from the membership form and
    b) it seemed that subName would be more often used

Comments

@mattwire if you confirm that you think this sub-commit is good to go I will merge as a reviewers's commit

@eileenmcnaughton
Copy link
Contributor Author

@mattwire to tease out a bit more of the bigger approach....

I have some thoughts -

  1. we looked at using the trait approach - (ie. this was my first cut & you did a second one ). What I potentially LIKE about the trait approach is we could include it from the parent by simply using an 'if function exists' type function. I don't think we can 100% prevent having to 'mark' each form that we want custom data added to in some way - a property, a function, a trait inclusion or whatever - since we need to do some form of whitelisting

  2. I really want to get my head around syncing the address custom data block into our overall approach - it adds some extra challenges - but they also apply to email, phone etc blocks

  3. once we have replaced those 3 repetitive lines with addCustomDataToForm I think it makes sense to re-cut the functions that make up addCustomDataToForm - there is not a great logical separation between what they do IMHO and they are hard to add a test to. I'd rather see the extraction of params from the form & urls distinct from the handling of them

  4. I'm still not convinced we should enable any additional entities by default - only that they should be enable-able. (FWIW the 2 entities I currently care about are RelationshipType and Email)

5)if we are doing a lot of form-intensive testing we might want to take the chance to convert some datepicker fields on those same forms while we are at it.

@mattwire
Copy link
Contributor

mattwire commented May 8, 2018

  • (r-explain) PASS
  • (r-test) Undecided
  • (r-code) PASS
  • (r-doc) PASS (functions have detailed docblocks)
  • (r-maint) PASS (stepping stone towards common methods to add custom data to forms)
  • (r-run) Undecided: PASS (works as before)
  • (r-user) Undecided: PASS (no change for user)
  • (r-tech) Undecided: PASS

This is a code improvement that will make it easier to add custom data to any form.

@mattwire
Copy link
Contributor

mattwire commented May 8, 2018

@eileenmcnaughton Merge on pass

@monishdeb
Copy link
Member

Merging as per tag.

@monishdeb monishdeb merged commit 8149248 into civicrm:master May 8, 2018
@eileenmcnaughton eileenmcnaughton deleted the custom_data branch May 8, 2018 12:04
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request May 14, 2018
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request May 15, 2018
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.

4 participants