Exemple #1
0
 /**
  * Set the configuration for all plugins.
  *
  * @param ConfigInterface $config
  *    A configuration object containing only configuration for all plugins
  */
 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);
             }
         }
     }
 }