You are here

function hosting_alias_get_aliases in Hosting 7.4

Same name and namespace in other branches
  1. 5 alias/hosting_alias.module \hosting_alias_get_aliases()
  2. 6.2 alias/hosting_alias.module \hosting_alias_get_aliases()
  3. 7.3 alias/hosting_alias.module \hosting_alias_get_aliases()

Retrieve a list of aliases for a site.

Parameters

Object $node: The site to get the aliases for.

int $type: Restrict the type of aliases returned, defaults to returning all aliases. Should be one of:

Return value

array An array of aliases for the given site.

3 calls to hosting_alias_get_aliases()
drush_hosting_alias_pre_hosting_task in alias/hosting_alias.drush.inc
@file Drush include for the hosting_alias module.
hosting_alias_form_data in alias/hosting_alias.module
Alter the node form for a site to add the aliases and redirection items.
hosting_alias_node_load in alias/hosting_alias.module
Implements hook_node_load().

File

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

Code

function hosting_alias_get_aliases($node, $type = NULL) {
  if (empty($node->vid)) {
    return array();
  }
  $alias = array();
  $query = db_select('hosting_site_alias')
    ->addTag('hosting_alias_get_aliases')
    ->fields('hosting_site_alias', array(
    'alias',
  ))
    ->condition('vid', $node->vid)
    ->orderBy('alias', 'ASC');
  if (!is_null($type)) {
    $query
      ->condition('automatic', $type);
  }
  $result = $query
    ->execute();
  foreach ($result as $obj) {
    $alias[] = $obj->alias;
  }
  $alias = array_unique($alias);
  if (count($alias)) {
    return $alias;
  }
  return array();
}