You are here

protected function ConfigSyncSnapshotter::listModulesInDependencyOrder in Configuration Synchronizer 8.2

Returns a list of specified modules sorted in order of dependency.

Parameters

string[] $module_list: An array of module names.

Return value

string[] An array of module names.

1 call to ConfigSyncSnapshotter::listModulesInDependencyOrder()
ConfigSyncSnapshotter::createSnapshot in src/ConfigSyncSnapshotter.php
Takes a snapshot of configuration from all installed modules and themes.

File

src/ConfigSyncSnapshotter.php, line 191

Class

ConfigSyncSnapshotter
The ConfigSyncSnapshotter provides helper functions for taking snapshots of extension-provided configuration.

Namespace

Drupal\config_sync

Code

protected function listModulesInDependencyOrder($module_list) {
  $module_list = array_combine($module_list, $module_list);

  // Get a list of modules with dependency weights as values.
  $module_data = $this->moduleExtensionList
    ->getList();

  // Set the actual module weights.
  $module_list = array_map(function ($module) use ($module_data) {
    return $module_data[$module]->sort;
  }, $module_list);

  // Sort the module list by their weights (reverse).
  arsort($module_list);
  return array_keys($module_list);
}