Skip to content

Instantly share code, notes, and snippets.

@m7v
Last active October 13, 2015 12:35
Show Gist options
  • Save m7v/3c723f5458223293dac0 to your computer and use it in GitHub Desktop.
Save m7v/3c723f5458223293dac0 to your computer and use it in GitHub Desktop.
Robo tasks for drupal
<?php
class RoboFile extends \Robo\Tasks
{
private function DrupalExec($siteprefix, $command, $instance) {
$sitenames = array(
'ex1' => 'examle1.com',
'ex2' => 'examle2.com',
'ex3' => 'examle3.com',
'all' => array(
'examle1.com',
'examle2.com',
'examle3.com',
)
);
$instance_prefix = '';
if ($instance) {
$instance_prefix = "@.{$instance}";
}
if (is_array($sitenames[$siteprefix])) {
$task = $this->taskParallelExec();
foreach ($sitenames[$siteprefix] as $sitename) {
$task->printed(TRUE);
$task->process("drush $instance_prefix $command -l {$sitename}");
}
$task->run();
}
else {
$this->taskExecStack()
->stopOnFail()
->printed(TRUE)
->exec("drush $instance_prefix $command -l {$sitenames[$siteprefix]}")
->run();
}
}
/**
* Clear drupal cache
*/
public function DCCA($siteprefix, $instance = NULL) {
$this->DrupalExec($siteprefix, 'cc all', $instance);
}
/**
* Clear drupal cache
*/
public function DEval($siteprefix, $instance = NULL, $function = 'function()') {
$this->DrupalExec($siteprefix, "eval '{$function}'", $instance);
}
/**
* Revert all features
*/
public function DFRA($siteprefix, $instance = NULL) {
$this->DrupalExec($siteprefix, 'fra -y --force', $instance);
}
/**
* Update database
*/
public function DUDB($siteprefix, $instance = NULL) {
$this->DrupalExec($siteprefix, 'updb -y', $instance);
}
/**
* Login like admin
*/
public function DULI($siteprefix, $instance = NULL) {
$this->DrupalExec($siteprefix, 'uli --browser=0', $instance);
}
/**
* Run cron
*/
public function DRC($siteprefix, $instance = NULL) {
$this->DrupalExec($siteprefix, 'elysia-cron', $instance);
}
/**
* Enable
*/
public function DME($siteprefix, $instance = NULL, $module = 'devel') {
$this->DrupalExec($siteprefix, "en $module -y", $instance);
}
/**
* Disa
*/
public function DME($siteprefix, $instance = NULL, $module = 'devel') {
$this->DrupalExec($siteprefix, "dis $module -y", $instance);
}
/**
* Deploy instance
* -run update database
* -run clear cache
* -run features revert;
*/
public function DDeploy($siteprefix, $instance = NULL) {
$this->DUDB($siteprefix, $instance);
$this->DFRA($siteprefix, $instance);
$this->DCCA($siteprefix, $instance);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment