public function getRepositoryInterface()
{
$interfaces = $this->config()->repository_interfaces;
/* Look for each whitelisted hostname */
foreach ($interfaces as $host => $interface) {
/* See if the CVS Path is for this hostname, followed by some junk (maybe a port), then the path */
if (preg_match('{^[^.]*' . $host . '(.*?)([/a-zA-Z].+)}', $this->CVSPath, $match)) {
$path = $match[2];
$scheme = isset($interface['scheme']) ? $interface['scheme'] : 'https';
$host = isset($interface['host']) ? $interface['host'] : $host;
$regex = isset($interface['regex']) ? $interface['regex'] : ['\\.git$' => ''];
$components = explode('.', $host);
foreach ($regex as $pattern => $replacement) {
$path = preg_replace('/' . $pattern . '/', $replacement, $path);
}
$uxurl = Controller::join_links($scheme . '://', $host, $path);
if (array_key_exists('commit', $interface) && $interface['commit'] == false) {
$commiturl = false;
} else {
$commiturl = Controller::join_links($uxurl, isset($interface['commit']) ? $interface['commit'] : 'commit');
}
return new ArrayData(['Name' => isset($interface['name']) ? $interface['name'] : ucfirst($components[0]), 'Icon' => isset($interface['icon']) ? $interface['icon'] : 'deploynaut/img/git.png', 'URL' => $uxurl, 'CommitURL' => $commiturl]);
}
}
}