global_gateway-8.x-1.x-dev/global_gateway.module

global_gateway.module
<?php

/**
 * @file
 * Provides plugins and UI pages to work with different regions, languages.
 */

/**
 * Implements hook_modules_uninstalled().
 *
 * Remove orphaned plugins from negotiation settings.
 */
function global_gateway_modules_uninstalled($modules) {
  $definitions = \Drupal::service('plugin.manager.global_gateway_region_negotiation_type')->getDefinitions();

  $types = array_intersect_key(
    \Drupal::config('global_gateway.negotiator')->get('types'),
    $definitions
  );

  if (!empty($types)) {
    \Drupal::configFactory()
      ->getEditable('global_gateway.negotiator')
      ->set('types', $types)
      ->save();
  }
}

/**
 * Implements hook_preprocess_HOOK().
 */
function global_gateway_preprocess_page(&$vars) {
  // Transfer detected region code to the JS.
  $vars['#attached']['drupalSettings']['regionCode'] = \Drupal::service('global_gateway_region_negotiator')
    ->negotiateRegion();
  // Attach global_gateway library for all pages,
  // without attaching to a certain block.
  $vars['#attached']['library'][] = 'global_gateway/global_gateway';
}

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

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