marketing_cloud_example needs a hook_help() function.

Text:

The Marketing Cloud Example module provides an example webform that accepts multiple mobile numbers and SMS text. It then uses a custom webform handler to make a "Post Message to Number" request.

It assumes that you already have an account with Salesforce, and have set up an SMS template, that it will override.

Assuming that you have already configured the Marketing Cloud module: To configure this module, open up the "Marketing Cloud Example" webform >> settings >> emails/handlers >> + add handler. Then click on "Add handler" for "Marketing Cloud Example". Enter the Short code for the message ID from Salesforce and click on save.

Function submitForm() shows a sample generation of the JSON payload, calling the service and handling the results.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

john_a created an issue. See original summary.

john_a’s picture

Status: Active » Needs review
FileSize
1.62 KB

Patch create, please review.

john_a’s picture

Accidentally added a use statement in the patch, redone

john_a’s picture

Assigned: Unassigned » john_a
Status: Needs review » Needs work

This is not working as expected, the help is appearing on the config page, and is displayed twice on the help page.

msankhala’s picture

  1. +++ b/modules/marketing_cloud_example/marketing_cloud_example.module
    @@ -0,0 +1,33 @@
    + * This is the Marketing Cloud Example sub-module for demonstrating how to use marketing_cloud.
    

    line length exceeds 80 characters. You can shorten it something like Marketing Cloud Example for demonstrating how to use marketing_cloud.

  2. +++ b/modules/marketing_cloud_example/marketing_cloud_example.module
    @@ -0,0 +1,33 @@
    +function marketing_cloud_example_help() {
    

    hook_help() in d8 has these two arguments $route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match
    those can be used in switch statement in hook_help.

  3. +++ b/modules/marketing_cloud_example/marketing_cloud_example.module
    @@ -0,0 +1,33 @@
    +  $output = '';
    

    Best way to implement hook_help is to return the content of README.md/txt file as content returned by hook_help.

    Add a README.md file inside this module and then return the content of that file inside hook_help. This way you can avoid maintaining documentation in two places. See https://www.drupal.org/docs/develop/documenting-your-project/module-docu... for more detail.

surbz’s picture

@msankhala Thanks for the covering every detail on writing a good hook_help() in your review.
I have addressed the feedback in #5 in this patch.

surbz’s picture

Status: Needs work » Needs review
msankhala’s picture

Status: Needs review » Needs work
  1. diff --git a/modules/marketing_cloud/modules/marketing_cloud_example/marketing_cloud_example.module b/modules/marketing_cloud/modules/marketing_cloud_example/marketing_cloud_example.module
    

    Patch should be created from inside the marketing_cloud folder. You created the patch from Drupal core folder which added path like modules/marketing_cloud/modules/marketing_cloud_example in patch. Someone may have this module at modules/contrib/marketing_cloud/modules/marketing_cloud_example

  2. +++ b/modules/marketing_cloud/modules/marketing_cloud_example/marketing_cloud_example.module
    @@ -0,0 +1,31 @@
    +      $text = file_get_contents(dirname(__FILE__) . "/README.md");
    

    Use single quote around "README.md" to maintain consistency. I have also updated doc.

surbz’s picture

surbz’s picture

Status: Needs work » Needs review
john_a’s picture

Thanks @msankhala & @surbz,

That works perfectly. I've added a new dependency for the markdown module into the marketing_cloud module - so that the page renders correctly.

Please can you review.

msankhala’s picture

+++ b/modules/marketing_cloud_example/marketing_cloud_example.module
@@ -0,0 +1,30 @@
+      if (!\Drupal::moduleHandler()->moduleExists('markdown')) {

@john_a You do not need to add this as a dependency because hook_help() adds a check for markdown module so this is an optional dependency. If you add this as dependency then it stops user to install module until the dependency is satisfied. You can mention about markdown module in README.md file itself so that user can install it if he wants to see markdown version of help.

msankhala’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm patch. #9 applies cleanly and shows the README.md contents under admin/help/marketing_cloud_example

john_a’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Applying patch #9, great work @serbz, thanks for the advice @msankhala.

john_a’s picture

Status: Patch (to be ported) » Fixed
john_a’s picture

Status: Fixed » Closed (fixed)
john_a’s picture

Assigned: john_a » Unassigned