updating the salesforce suite to drupal 8: major changes for a big module

21
1 ©2016 Acquia Inc. — Confidential and Proprietary Presented by Message Agency Updating Salesforce Suite to D8: Major Changes for a Big Module

Upload: acquia

Post on 22-Jan-2018

353 views

Category:

Software


0 download

TRANSCRIPT

1 ©2016 Acquia Inc. — Confidential and Proprietary

Presented by Message Agency

Updating Salesforce Suite to D8:

Major Changes for a Big Module

2 ©2016 Acquia Inc. — Confidential and Proprietary

Who Are We?Aaron Bauman– 8+ years Drupal developer & module

maintainer– [email protected]– drupal.org/u/aaronbauman

Alex Rhodes– 7 year Drupal developer– [email protected]– drupal.org/u/ironsizide

3 ©2016 Acquia Inc. — Confidential and Proprietary

Why Are We Here?We’re here to talk about navigatingDrupal 8 APIs for Drupal 7 developers, through the lens of Salesforce module.

– Entity & Entity Storage API– Plugin API– Events Dispatcher– Queue API– Building a REST client for Salesforce

API– Route Subscribers– Service Providers

4 ©2016 Acquia Inc. — Confidential and Proprietary

Project Overview– Mappings (Entity API, Plugin API,

Route Subscriber)– Pull (Queue API)– Push (Queue API, custom)– Push/Pull Events (Events

Dispatcher)– Salesforce REST API Client (Service)– Encrypt support (Service Provider

alter)

5 ©2016 Acquia Inc. — Confidential and Proprietary

New Features & Bug Fixes– Intelligent use of API clients– Multiple mappings per entity type– Improved error handling and logging– Merge support– Encryption support– Fully extensible and pluggable

6 ©2016 Acquia Inc. — Confidential and Proprietary

Salesforce Push Diagram

http://goo.gl/tmKw6w

7 ©2016 Acquia Inc. — Confidential and Proprietary

Salesforce Pull Diagram

http://goo.gl/2X3BG3

8 ©2016 Acquia Inc. — Confidential and Proprietary

Demo Slide– Elevator music goes here

9 ©2016 Acquia Inc. — Confidential and Proprietary

Entity & Entity Storagenode_load()

is now

\Drupal::service(

'entity_type.manager')

->getStorage('node')

->load()

This is... verbose. Why is it better?– Extensibility– Dependability– Testability

10 ©2016 Acquia Inc. — Confidential and Proprietary

Entity & Entity StorageExamples– Drupal\salesforce_mapping\

– Entity\MappedObject

– Entity\SalesforceMapping

– SalesforceMappingStorage

– MappedObjectStorage

11 ©2016 Acquia Inc. — Confidential and Proprietary

Plugin APIhook_my_module_new_api_info

+ module_invoke_all

+ hook_my_module_new_api_data

+hook_my_module_new_api_CALLBACK_FUN

CTION

is now

\Drupal::service(

'my_module.plugin_manager')

->getDefinitions()

This is more concise. Why is this better?– Extensibility– Dependability– Testability

12 ©2016 Acquia Inc. — Confidential and Proprietary

Plugin APIExamples– Drupal\salesforce_mapping\

– SalesforceMappingFieldPluginManager

– SalesforceMappingFieldPluginBase

– Plugin\SalesforceMappingField\Properties

– Plugin\SalesforceMappingField\Broken

13 ©2016 Acquia Inc. — Confidential and Proprietary

Queue APIhook_cron_queue_info

is now

Plugin\QueueWorker

Why is this better?– Extensibility– Dependability– Testability

14 ©2016 Acquia Inc. — Confidential and Proprietary

Queue APIExamples– Drupal\salesforce_pull\

– QueueHandler

– Plugin\QueueWorker\PullBase

– Drupal\salesforce_push\

– PushQueue

– Plugin\SalesforcePushQueueProcessor\Rest

15 ©2016 Acquia Inc. — Confidential and Proprietary

Events APIExamples– Drupal\salesforce\

SalesforceEvents

– Drupal\salesforce_push\Plugin\

SalesforcePushQueueProcessor\

Rest

module_invoke_all()

is now

\Drupal::service(

'event_dispatcher')

->dispatch()

16 ©2016 Acquia Inc. — Confidential and Proprietary

Salesforce REST API ClientDrupal 7+ Salesforce client encapsulated in a

class- Class file contains 3 different classes+ Internal methods are atomized- Return values are not reliable

Drupal 8+ PSR-4 enforces namespacing, class hierarchy, interface+ Class wrappers for return values+ Type-hinting whenever possible+ Salesforce Exception classes to encapsulate error responses

Drupal\salesforce\Rest\RestClient

17 ©2016 Acquia Inc. — Confidential and Proprietary

Lower barrier to implementing new APIs– Extend a class, rather than copy-pasting and re-writing– Plugin API and Annotations reduce overhead and time to ship– Lots of previously hard/tedious things we now get "for free"

Key Takeaways

18 ©2016 Acquia Inc. — Confidential and Proprietary

OOP, finally– Reliable arguments and return values make devs happy– Traits make it easy to reuse components across inheritance, extensibility, and

interfaces– Consistent expectations for all objects. No more stdClass, yay!

Key Takeaways

19 ©2016 Acquia Inc. — Confidential and Proprietary

Early architecture decisions are important– Naming conventions are crucial, and tedious to change– Writing tests early (or full TDD) is faster than writing tests for a large, existing stack– Dependency injection and encapsulation, every time– Not sure the best way to do something?

Look for a pattern in core.

Key Takeaways

20 ©2016 Acquia Inc. — Confidential and Proprietary

Navigating and learning D8 can be tedious– Dozens of nesting levels and wrappers– Namespacing means class names are no longer unique– Keep a copy of core.services.yml handy at all times– Use a smart IDE, or a good documentation tool like Dash– Be ready to search d.o documentation, changelogs, and issue queue for "the D8

way" to do things– Examples module implements dozens of different APIs

Key Takeaways

21 ©2016 Acquia Inc. — Confidential and Proprietary

Thank You

https://www.drupal.org/project/salesforce

https://www.messageagency.com