function _thunder_check_triggering_modules in Thunder 8.2
Same name and namespace in other branches
- 8.3 thunder.profile \_thunder_check_triggering_modules()
- 8.4 thunder.profile \_thunder_check_triggering_modules()
Check if provided triggering modules are one of the newly installed modules.
This function is helper for thunder_modules_installed(). Using it in another context is not recommended.
Parameters
array $modules: The list of the modules that were newly installed.
array $triggering_modules: The list of triggering modules required for executing some action.
Return value
bool Returns if triggering module is newly installed.
See also
1 call to _thunder_check_triggering_modules()
- thunder_modules_installed in ./thunder.profile 
- Implements hook_modules_installed().
File
- ./thunder.profile, line 257 
- Enables modules and site configuration for a thunder site installation.
Code
function _thunder_check_triggering_modules(array $modules, array $triggering_modules) {
  // Check that at least one triggering module is in list of the modules that
  // were newly installed.
  $triggering_not_installed_modules = array_diff($triggering_modules, $modules);
  if (count($triggering_not_installed_modules) === count($triggering_modules)) {
    return FALSE;
  }
  // All required triggering modules are in the list of the modules that were
  // newly installed.
  if (empty($triggering_not_installed_modules)) {
    return TRUE;
  }
  /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
  $module_handler = Drupal::moduleHandler();
  $active_modules = array_keys($module_handler
    ->getModuleList());
  // Ensure that all triggering modules modules are installed on system.
  $required_not_active_modules = array_diff($triggering_not_installed_modules, $active_modules);
  return empty($required_not_active_modules);
}