You are here

protected function FeaturesManager::initConfigCollection in Open Social 8.8

Loads configuration from storage into a property.

File

modules/social_features/social_core/src/FeaturesRemoval/FeaturesManager.php, line 123

Class

FeaturesManager
Overrides the features FeaturesManager.

Namespace

Drupal\social_core\FeaturesRemoval

Code

protected function initConfigCollection($reset = FALSE) {
  if ($reset || empty($this->configCollection)) {
    $config_collection = [];
    $config_types = $this
      ->listConfigTypes();
    $dependency_manager = $this
      ->getFeaturesConfigDependencyManager();

    // List configuration provided by installed features.
    $existing_config = $this
      ->listExistingConfig(NULL);
    $existing_config_by_directory = $this->extensionStorages
      ->listAllByDirectory();
    foreach (array_keys($config_types) as $config_type) {
      $config = $this
        ->listConfigByType($config_type);
      foreach ($config as $item_name => $label) {
        $name = $this
          ->getFullName($config_type, $item_name);
        $data = $this->configStorage
          ->read($name);
        $config_collection[$name] = new ConfigurationItem($name, $data, [
          'shortName' => $item_name,
          'label' => $label,
          'type' => $config_type,
          'dependents' => array_keys($dependency_manager
            ->getDependentEntities('config', $name)),
          // Default to the install directory.
          //            'subdirectory' => isset($existing_config_by_directory[$name]) ? $existing_config_by_directory[$name] : InstallStorage::CONFIG_INSTALL_DIRECTORY,
          'subdirectory' => isset($existing_config_by_directory[$name]) ? $existing_config_by_directory[$name] : 'config/features_removal',
          'package' => '',
          'providerExcluded' => NULL,
          'provider' => isset($existing_config[$name]) ? $existing_config[$name] : NULL,
          'packageExcluded' => [],
        ]);
      }
    }
    $this
      ->setConfigCollection($config_collection);
  }
}