You are here

function hosting_alias_hosting_automatic_aliases in Hosting 7.4

Same name and namespace in other branches
  1. 7.3 alias/hosting_alias.module \hosting_alias_hosting_automatic_aliases()

Implements hook_hosting_automatic_aliases().

Generate automatic subdomain aliases.

See also

hosting_alias_hosting_automatic_aliases_alter().

File

alias/hosting_alias.module, line 565
Allow sites to have domain aliases that they can be accessed with.

Code

function hosting_alias_hosting_automatic_aliases($url) {
  $aliases = [];
  if ($sub = variable_get('hosting_alias_subdomain', FALSE)) {
    if (!preg_match("/\\." . preg_quote($sub, '/') . "\$/", $url)) {
      if (variable_get('hosting_alias_subdomain_replace_dash', TRUE)) {
        $find[] = '-';
        $replace[] = variable_get('hosting_alias_subdomain_dash_substitute', '--');
      }
      $find[] = '.';
      $replace[] = '-';
      $aliases[] = str_replace($find, $replace, $url) . "." . trim($sub, ".");
    }
  }
  return $aliases;
}