Skip to content

Instantly share code, notes, and snippets.

@threeiem
Last active August 29, 2015 14:25
Show Gist options
  • Save threeiem/77e8e666b965239919fc to your computer and use it in GitHub Desktop.
Save threeiem/77e8e666b965239919fc to your computer and use it in GitHub Desktop.
Drush to return all the local aliases for drush. Used for multisite installations.
<?php
/**
* Get Local Alaises.
*
* Returns an array that is indexed by it's alias ID without that '@'.
*
* @return array Returns an array of local sites in the Drush site aliases.
*/
function _multisite_get_local_alias($group = NULL) {
$alias = array();
$result = (array) _drush_sitealias_find_and_load_all_aliases();
if (empty($group) == TRUE) {
foreach ($result as $id => $site) {
if (empty($site['root']) == FALSE) {
$alias[$site['#name']] = $site;
}
}
} else {
foreach ($results as $id => $site) {
$current_group = substr($id, 0, strpos($id, '.'));
if ($group == $current_group) {
$alias[$sites['#name']] = $site;
}
}
}
return $alias;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment