function _apachesolr_drush_variable_format in Apache Solr Search 7
Same name and namespace in other branches
- 8 drush/apachesolr.drush.inc \_apachesolr_drush_variable_format()
- 6.3 drush/apachesolr.drush.inc \_apachesolr_drush_variable_format()
Format a specific variable
Parameters
$value:
$format:
Return value
bool|int|string
1 call to _apachesolr_drush_variable_format()
- drush_apachesolr_solr_variable_set in drush/
apachesolr.drush.inc - Command callback. Set a variable.
File
- drush/
apachesolr.drush.inc, line 523 - drush integration for apachesolr.
Code
function _apachesolr_drush_variable_format($value, $format) {
if ($format == 'auto') {
if (is_numeric($value)) {
$format = 'integer';
}
elseif ($value == 'TRUE' || $value == 'FALSE') {
$format = 'bool';
}
}
// Now, we parse the object.
switch ($format) {
case 'integer':
$value = (int) $value;
break;
case 'bool':
case 'boolean':
if ($value == 'TRUE') {
$value = TRUE;
}
elseif ($value == 'FALSE') {
$value = FALSE;
}
else {
$value = (bool) $value;
}
break;
case 'json':
$value = drush_json_decode($value);
break;
}
return $value;
}