adimo-8.x-1.0/adimo.module

adimo.module
<?php

/**
 * @file
 * Contains adimo.module.
 */

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function adimo_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    // Main module help for the tint module.
    case 'help.page.adimo':
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
      $output .= '<p>' . t('Integration with the adimo where to buy 
      integration.') . '</p>';

      break;

    default:
  }
  return $output;
}

/**
 * Implements hook_theme().
 */
function adimo_theme($existing, $type, $theme, $path) {
  return [
    'adimo' => [
      'variables' => [
        'data_touchpoint_id' => NULL,
        'html_id'            => NULL,
      ],
    ],
  ];
}

/**
 * Implements hook_page_attachments().
 */
function adimo_preprocess_field(array &$variables) {
  // Check for module exist or enable.
  $moduleHandler = Drupal::service('module_handler');
  if ($moduleHandler->moduleExists('adimo')) {
    if ($variables['field_type'] == 'field_adimo') {
      // Add js Library based on field integration widget.
      $data_touchpoint_id = $variables['element'][0]['#data_touchpoint_id'];
      $html_id = $variables['element'][0]['#html_id'];
      // Touch point id to get adimo widget.
      $variables['#attached']['drupalSettings']['adimo'][$html_id] = $data_touchpoint_id;
    }
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc