Commit 4ad2afe9 authored by The Great Git Migration's avatar The Great Git Migration
Browse files

This commit was manufactured as part of Drupal's Great Git Migration to

create tag 'DRUPAL-6--2-0-BETA1'.

Sprout from DRUPAL-6--2 2009-11-20 22:51:18 UTC young hahn <yhahn@264833.no-reply.drupal.org> 'Initial commit of DRUPAL-6--2 branch of strongarm.'
Delete:
    strongarm.drush.inc
parent 39f64eb7
<?php
// $Id$
/**
* @file
* Drush integration for Strongarm. Provides commands to export variables.
*/
/**
* Implementation of hook_drush_help().
*/
function strongarm_drush_help($section) {
switch ($section) {
case 'drush:strongarm':
return dt("Export Drupal variables. Without any arguments a list of all variables will be shown. If arguments are specified they'll be var_exported to stdout.");
}
}
/**
* Implementation of hook_drush_command().
*/
function strongarm_drush_command() {
$items['strongarm'] = array(
'callback' => 'strongarm_drush_export',
'description' => 'Export variable(s).',
);
return $items;
}
// Callback for strongarm command.
function strongarm_drush_export() {
$vars = func_get_args();
if (empty($vars)) {
// Pull all variables from DB.
$result = db_query('SELECT name FROM variable');
$variables = array();
while ($variable = db_fetch_object($result)) {
$variables[$variable->name] = $variable->name;
}
// Pull all variables defined in hook_strongarm(), merge them in.
$strongarmed = drupal_map_assoc(array_keys(strongarm_get_conf(TRUE, TRUE)));
$variables = $variables + $strongarmed;
ksort($variables);
// Output result, flag strongarmed variables.
$rows = array(array('Strongarmed', 'Variable name'));
foreach ($variables as $variable) {
$flag = $strongarmed[$variable] ? '*' : '';
$rows[] = array($flag, $variable);
}
drush_print_table($rows, TRUE);
}
else {
$exports = array();
foreach ($vars as $v) {
// We use the very unlikely 'DRUSH_STRONGARM_NO_VALUE_HERE' as the
// default value which *should* be ok, right?
$variable = variable_get($v, 'DRUSH_STRONGARM_NO_VALUE_HERE');
if ($variable !== 'DRUSH_STRONGARM_NO_VALUE_HERE') {
$exports[$v] = $variable;
}
}
drush_print(var_export($exports));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment