You are here

hosting_alias.api.php in Hosting 7.4

Same filename and directory in other branches
  1. 7.3 alias/hosting_alias.api.php

Hooks provided by the hosting_alias module.

File

alias/hosting_alias.api.php
View source
<?php

/**
 * @file
 * Hooks provided by the hosting_alias module.
 */

/**
 * Provide automatic aliases to generate.
 *
 * @see hosting_alias_automatic_aliases().
 */
function hook_hosting_automatic_aliases($url) {
  $aliases = [];

  // Add a couple automatic aliases.
  foreach ([
    'www',
    'web1',
  ] as $subdomain) {
    $aliases[] = $subdomain . '.' . $url;
  }
  return $aliases;
}

/**
 * Alter the list of automatic aliases to create.
 *
 * @see hosting_alias_automatic_aliases().
 */
function hook_hosting_automatic_aliases_alter(&$aliases, $context) {
  $alias_to_remove = 'web1.' . $context['url'];
  $key = array_search($alias_to_remove, $aliases);
  if ($key !== FALSE) {

    // Remove our unwanted alias.
    unset($aliases[$key]);
  }
}

Functions

Namesort descending Description
hook_hosting_automatic_aliases Provide automatic aliases to generate.
hook_hosting_automatic_aliases_alter Alter the list of automatic aliases to create.