Configuration is stored per type: system and local, and is always merged into the "all" type which is only used for getting and not setting. Note that the Config class does not check if the provided directories are valid or even exist. This class is only for holding configuration.
Example #1
0
 /**
  * @return Client
  */
 protected function buildGitHubClient()
 {
     $cachedClient = new CachedHttpClient(['cache_dir' => $this->globalConfig->get('cache-dir'), 'base_url' => $this->config['base_url']]);
     $client = new Client($cachedClient);
     if (false !== getenv('GITHUB_DEBUG')) {
         $logPlugin = LogPlugin::getDebugPlugin();
         $httpClient = $client->getHttpClient();
         $httpClient->addSubscriber($logPlugin);
     }
     $client->setOption('base_url', $this->config['base_url']);
     $this->url = rtrim($this->config['base_url'], '/');
     $this->domain = rtrim($this->config['repo_domain_url'], '/');
     return $client;
 }
Example #2
0
 /**
  * Dump configuration to the related config-file.
  *
  * The config-file is automatically determined using
  * type.
  *
  * @param Config $config
  * @param string $type
  *
  * @return string
  */
 public static function dumpToFile(Config $config, $type)
 {
     if ($type === Config::CONFIG_LOCAL) {
         $filename = $config->get('local_config');
         if (null === $filename) {
             throw new \RuntimeException('Local configuration is not loaded and therefore it cannot be dumped.');
         }
     } elseif ($type === Config::CONFIG_SYSTEM) {
         $filename = $config->get('home_config');
     } else {
         throw new \InvalidArgumentException(sprintf('Config slot "%s" is not valid for dumping to a file "%s", use either: ' . 'Config::CONFIG_SYSTEM or Config::CONFIG_LOCAL.', $type));
     }
     // Testing compatibility, write directly as there is no risk of problems
     if ('vfs://' === substr($filename, 0, 6)) {
         file_put_contents($filename, Yaml::dump($config->toArray($type)));
     } else {
         self::getFilesystem()->dumpFile($filename, "# Gush configuration file, any comments will be lost.\n" . Yaml::dump($config->toArray($type), 2));
     }
     return $filename;
 }