public function __construct(SystemConfigurationInterface $systemConfiguration, ModuleConfigurationInterface $moduleConfiguration)
{
// load the configuration values
$defaultTtl = $moduleConfiguration->getParam(AbstractStorageProvider::DEFAULT_TTL);
// query whether or not the default TTL is an integer
if (!is_int($defaultTtl)) {
throw new \Exception('Default TTL must be an integer.');
}
// declare the array for the DNS records
$dnsRecords = array();
// iterate over the system configuration and create DNS A records from the found virtual hosts
foreach ($systemConfiguration->getContainers() as $containerNode) {
foreach ($containerNode->getServers() as $serverNode) {
foreach ($serverNode->getVirtualHosts() as $virtualHost) {
if (sizeof($dnsNames = explode(' ', $virtualHost->getName())) > 0) {
foreach ($dnsNames as $dnsName) {
// add the IPv4 + IPv6 address for localhost
$dnsRecords[$dnsName]['A'] = array('127.0.0.1');
$dnsRecords[$dnsName]['AAAA'] = array('::1');
}
}
}
}
}
// set the default TTL and the DNS records
$this->dsTtl = $defaultTtl;
$this->dnsRecords = $dnsRecords;
}