You are here

function eu_cookie_compliance_module_set_weight in EU Cookie Compliance (GDPR Compliance) 8

Same name and namespace in other branches
  1. 7.2 eu_cookie_compliance.install \eu_cookie_compliance_module_set_weight()
  2. 7 eu_cookie_compliance.install \eu_cookie_compliance_module_set_weight()

Helper function to set module weight.

3 calls to eu_cookie_compliance_module_set_weight()
EuCookieComplianceConfigForm::submitForm in src/Form/EuCookieComplianceConfigForm.php
Form submission handler.
eu_cookie_compliance_install in ./eu_cookie_compliance.install
Implements hook_install().
eu_cookie_compliance_update_8108 in ./eu_cookie_compliance.install
Change module weight to load after other modules, ensure all JSs are handled.

File

./eu_cookie_compliance.module, line 871
The main file for the EU Cookie Compliance module.

Code

function eu_cookie_compliance_module_set_weight() {
  $weight = 1;
  $exclude_modules = [
    'eu_cookie_compliance',
  ];

  // Allow other modules to exclude themselves.
  \Drupal::moduleHandler()
    ->alter('eu_cookie_compliance_module_weight_exclude', $exclude_modules);
  $extension_config = \Drupal::configFactory()
    ->get('core.extension');

  // Loop through all installed modules to find the highest weight.
  foreach ($extension_config
    ->get('module') as $module_name => $module_weight) {
    if ($module_weight > $weight && !in_array($module_name, $exclude_modules)) {
      $weight = $module_weight + 1;
    }
  }
  module_set_weight('eu_cookie_compliance', $weight);
}