Skip to content

Instantly share code, notes, and snippets.

@opi
Created October 29, 2012 08:46
Show Gist options
  • Save opi/3972431 to your computer and use it in GitHub Desktop.
Save opi/3972431 to your computer and use it in GitHub Desktop.
Drsuh commande to update site language domain
<?php
function MYMODULE_drush_command() {
$items = array();
$items['languages-domain'] = array(
'aliases' => array('lang-domain'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, // No bootstrap at all.
'options' => array(
'domain' => 'Specify domain (local, dev, prod)',
),
);
return $items;
}
function MYMODULE_drush_help($section) {
switch ($section) {
case 'drush:languages-domain':
return "Force domain data in language table.\nRequired option: --domain (local, dev, prod)";
break;
}
}
// Drush_command-name()
function drush_languages_domain() {
switch(drush_get_option('domain')) {
case 'local':
$domain = array(
'en' => 'http://local.domain.com',
'fr' => 'http://local-fr.domain.com',
'es' => 'http://local-es.domain.com',
);
break;
case 'dev':
$domain = array(
'en' => 'http://dev.domain.com',
'fr' => 'http://dev-fr.domain.com',
'es' => 'http://dev-es.domain.com',
);
break;
case 'prod':
$domain = array(
'en' => 'http://www.domain.com',
'fr' => 'http://fr.domain.com',
'es' => 'http://es.domain.com',
);
break;
default:
return drush_set_error("You must specify a valid domain");
break;
}
db_query("UPDATE {languages} SET domain = '". $domain['en'] ."' WHERE language = 'en'");
db_query("UPDATE {languages} SET domain = '". $domain['fr'] ."' WHERE language = 'fr'");
db_query("UPDATE {languages} SET domain = '". $domain['es'] ."' WHERE language = 'es'");
return drush_log("Languages domains has been modified to domain:" . drush_get_option('domain'), 'ok');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment