You are here

protected function FeaturesManager::initConfigCollection in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/FeaturesManager.php \Drupal\features\FeaturesManager::initConfigCollection()

Loads configuration from storage into a property.

1 call to FeaturesManager::initConfigCollection()
FeaturesManager::getConfigCollection in src/FeaturesManager.php
Gets an array of site configuration.

File

src/FeaturesManager.php, line 1214

Class

FeaturesManager
The FeaturesManager provides helper functions for building packages.

Namespace

Drupal\features

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,
          'package' => '',
          'providerExcluded' => NULL,
          'provider' => isset($existing_config[$name]) ? $existing_config[$name] : NULL,
          'packageExcluded' => [],
        ]);
      }
    }
    $this
      ->setConfigCollection($config_collection);
  }
}