strongarm.drush.inc 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Implementation of hook_drush_command().
  4. */
  5. function strongarm_drush_command() {
  6. $items = array();
  7. $items['strongarm-revert'] = array(
  8. 'description' => 'Revert all strongarmed variables from code to the database.',
  9. 'options' => array(
  10. 'force' => 'Reset all variables, including those that are marked as already being set to the database.',
  11. ),
  12. 'bootstrap' => 'DRUSH_BOOTSTRAP_DRUPAL_FULL',
  13. );
  14. return $items;
  15. }
  16. /**
  17. * Command callback for strongarm_revert.
  18. */
  19. function drush_strongarm_revert() {
  20. _drush_strongarm_revert(drush_get_option('force', FALSE));
  21. drush_log('Pushed variables from code to the database.', 'success');
  22. }
  23. /**
  24. * Handle the revert of variables into the database.
  25. */
  26. function _drush_strongarm_revert($force) {
  27. global $conf;
  28. $vars = strongarm_vars_load(TRUE, TRUE);
  29. foreach ($vars as $name => $var) {
  30. if ($force || !empty($var->in_code_only)) {
  31. if (!isset($conf[$name]) || $var->value != $conf[$name]) {
  32. variable_set($name, $var->value);
  33. }
  34. }
  35. }
  36. }