You are here

public function ConfigurableTrait::setConfig in Backup and Migrate 8.4

Set the configuration for all plugins.

Parameters

ConfigInterface $config: A configuration object containing only configuration for all plugins

1 call to ConfigurableTrait::setConfig()
ConfigurableTrait::__construct in lib/backup_migrate_core/src/Config/ConfigurableTrait.php
1 method overrides ConfigurableTrait::setConfig()
PluginManager::setConfig in lib/backup_migrate_core/src/Plugin/PluginManager.php
Set the configuration. Reconfigure all of the installed plugins.

File

lib/backup_migrate_core/src/Config/ConfigurableTrait.php, line 57

Class

ConfigurableTrait
Class ConfigurableTrait.

Namespace

BackupMigrate\Core\Config

Code

public function setConfig(ConfigInterface $config) {

  // Set the configuration object to the one passed in.
  $this->config = $config;

  // Add the init/default values to the config object so they will always exist.
  // @TODO: Make this cascade happen when the config key is requested.
  // That will allow read-only or runtime generation config object to be passed
  // This would work by creating a CascadeConfig object which takes an array
  // of ConfigInterface objects and queries each in order to find the given key.
  $defaults = $this
    ->configDefaults();
  $init = $this->init;
  foreach ([
    $init,
    $defaults,
  ] as $config_object) {
    foreach ($config_object
      ->toArray() as $key => $value) {
      if (!$this->config
        ->keyIsSet($key)) {
        $this->config
          ->set($key, $value);
      }
    }
  }
}