protected function loadConfig($file) { if (!is_readable($file)) { throw new \RuntimeException(sprintf('Can not read configuration file "%s".', $file)); } return Configuration::loadFromFile($file); }
public static function loadFromFile($file) { $yaml = Yaml::parse(file_get_contents($file)); $configuration = new Configuration(ProviderManager::fromDefaults()); if (isset($yaml['parameters'])) { $parameters = $yaml['parameters']; } else { $parameters = array(); } if (isset($yaml['hosts'])) { foreach ($yaml['hosts'] as $host => $hostData) { if (!isset($hostData['provider'])) { throw new InvalidHostException('No provider key set.', $host); } $providerId = $hostData['provider']; unset($hostData['provider']); $hostData = self::replacePlaceholders($hostData, $parameters); $configuration->addHost($host, $providerId, $hostData); } } return $configuration; }
/** * @expectedException \Z38\DynamicDns\Exception\InvalidHostException */ public function testLoadWithoutProvider() { $config = Configuration::loadFromFile(__DIR__ . '/config-noprovider.yml'); }
protected function updateHost(Configuration $config, $host, $ip) { $provider = $config->getHostProvider($host); $data = $config->getHostData($host); $provider->update($host, $ip, $data); }