salesforce_pull_process_records performs 2 separate, but roughly equivalent operations depending on whether it's processing a Create or an Update.

Additionally, repetitiveness of error and message handling can be reduced with another layer of indirection.

Comments

aaronbauman created an issue. See original summary.

aaronbauman’s picture

refactor attached
- reduced code by 34 lines
- reduced indent by 2 levels by adding helper function salesforce_pull_process_record()

aaronbauman’s picture

Status: Active » Needs review
asherry’s picture

Since this is a bit outdated, and so is a related issue which is #2694245: Multiple mapping for the same drupal entity, I'd like to propose a patch that incorporates some fixes for mappings, as well as dry-ing out the salesforce pull process in general.

I posted this patch here - https://www.drupal.org/node/2694245#comment-11903133, as well as a summary of the changes. For the projects we have this made it very easy to test one single mapping at a time, and I can post an example of that code if it's of interest.

asherry’s picture

Hi Aaron, I wanted to share my approach to this. I forked the salesforce repo and have my commits in a separate branch in hopes that we can discuss the changes and see if maybe with a few tweaks I can get something that can get committed.

I feel like the most important functions to separate out were the actual entity update and entity insert parts of the code, and my first phase was just creating an external include. The next phase in my opinion should be creating a SalesforcePullRecord class which would be able to encapsulate those particular actions better.

https://github.com/FreeflowDigital/salesforce/tree/refactor-salesforce-pull

aaronbauman’s picture

Status: Needs review » Closed (won't fix)

7.x is no longer supported

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.