You are here

public function ConfigListerWithProviders::listProviders in Configuration Update Manager 8

Sets up and returns the config providers list.

2 calls to ConfigListerWithProviders::listProviders()
ConfigListerWithProviders::getConfigProvider in src/ConfigListerWithProviders.php
Returns the provider of a given config object.
ConfigListerWithProviders::providerHasConfig in src/ConfigListerWithProviders.php
Lists the providers of a given type that actually have configuration.

File

src/ConfigListerWithProviders.php, line 82

Class

ConfigListerWithProviders
Provides methods related to config listing, including provider calculation.

Namespace

Drupal\config_update

Code

public function listProviders() {

  // Return the list if it has already been set up.
  if (count($this->providers)) {
    return $this->providers;
  }

  // Calculate the list of who provides which config, if it hasn't been set
  // up yet. List all of the profile, modules, and themes. Profile needs to
  // come last, so it will override config in modules and themes in our list,
  // matching what the config system does.
  $extensionsToDo = [];
  $profile = $this
    ->getProfileName();
  $modules = $this->moduleHandler
    ->getModuleList();
  foreach ($modules as $machine_name => $module) {
    if ($machine_name != $profile) {
      $extensionsToDo[] = [
        'module',
        $machine_name,
      ];
    }
  }
  $themes = $this->themeHandler
    ->listInfo();
  foreach ($themes as $machine_name => $theme) {
    $extensionsToDo[] = [
      'theme',
      $machine_name,
    ];
  }
  $extensionsToDo[] = [
    'profile',
    $profile,
  ];

  // For each extension, figure out if it has config, and make an index of
  // config item => provider.
  $this->extensionsWithConfig = [
    'profile' => [],
    'module' => [],
    'theme' => [],
  ];
  foreach ($extensionsToDo as $item) {
    $type = $item[0];
    $name = $item[1];
    $configs = array_merge($this
      ->listProvidedItems($type, $name), $this
      ->listProvidedItems($type, $name, TRUE));
    if (!empty($configs)) {
      $this->extensionsWithConfig[$type][$name] = $name;
      foreach ($configs as $config) {
        $this->providers[$config] = [
          $type,
          $name,
        ];
      }
    }
  }
  return $this->providers;
}