marketing_cloud_example.module 1.03 KB
Newer Older
1
<?php
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/**
 * @file
 * Adds example sub-module for demonstrating how to use Marketing Cloud.
 */

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function marketing_cloud_example_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.page.marketing_cloud_example':

      $text = file_get_contents(dirname(__FILE__) . '/README.md');
      if (!\Drupal::moduleHandler()->moduleExists('markdown')) {
19
20
        drupal_set_message('To view this page correctly, please install and
         enable the markdown module.');
21
22
23
24
25
26
27
28
29
30
31
32
33
        return '<pre>' . $text . '</pre>';
      }
      else {
        // Use the Markdown filter to render the README.
        $filter_manager = \Drupal::service('plugin.manager.filter');
        $settings = \Drupal::configFactory()->get('markdown.settings')->getRawData();
        $config = ['settings' => $settings];
        $filter = $filter_manager->createInstance('markdown', $config);
        return $filter->process($text, 'en');
      }
  }
  return NULL;
}