You are here

strongarm.drush.inc in Strongarm 7.2

Same filename and directory in other branches
  1. 6.2 strongarm.drush.inc
  2. 6 strongarm.drush.inc

File

strongarm.drush.inc
View source
<?php

/**
 * Implementation of hook_drush_command().
 */
function strongarm_drush_command() {
  $items = array();
  $items['strongarm-revert'] = array(
    'description' => 'Revert all strongarmed variables from code to the database.',
    'options' => array(
      'force' => 'Reset all variables, including those that are marked as already being set to the database.',
    ),
    'bootstrap' => 'DRUSH_BOOTSTRAP_DRUPAL_FULL',
  );
  return $items;
}

/**
 * Command callback for strongarm_revert.
 */
function drush_strongarm_revert() {
  _drush_strongarm_revert(drush_get_option('force', FALSE));
  drush_log('Pushed variables from code to the database.', 'success');
}

/**
 * Handle the revert of variables into the database.
 */
function _drush_strongarm_revert($force) {
  global $conf;
  $vars = strongarm_vars_load(TRUE, TRUE);
  foreach ($vars as $name => $var) {
    if ($force || !empty($var->in_code_only)) {
      if (!isset($conf[$name]) || $var->value != $conf[$name]) {
        variable_set($name, $var->value);
      }
    }
  }
}

Functions

Namesort descending Description
drush_strongarm_revert Command callback for strongarm_revert.
strongarm_drush_command Implementation of hook_drush_command().
_drush_strongarm_revert Handle the revert of variables into the database.