function coder_upgrade_query_to_array in Coder 7.2
Same name and namespace in other branches
- 7 coder_upgrade/conversions/call.inc \coder_upgrade_query_to_array()
Converts a url query string to an associative array.
Parameters
string $string:
Return value
PGPExpression The associative array.
2 calls to coder_upgrade_query_to_array()
- coder_upgrade_upgrade_call_drupal_goto_alter in coder_upgrade/
conversions/ call.inc - Implements hook_upgrade_call_drupal_goto_alter().
- coder_upgrade_upgrade_call_url_alter in coder_upgrade/
conversions/ call.inc - Implements hook_upgrade_call_url_alter().
File
- coder_upgrade/
conversions/ call.inc, line 1073 - Provides conversion routines applied to function calls.
Code
function coder_upgrade_query_to_array($string) {
// Create helper objects.
$editor = PGPEditor::getInstance();
$string = trim($string, "'\"");
if ($string == '') {
// Empty string is equivalent to NULL in this case.
return $editor
->expressionToStatement('NULL');
}
parse_str($string, $query_str);
// This removes a trailing comma from an inline array expression.
$editor
->getReader()
->setPreserveArrayFormat(FALSE);
$query = $editor
->expressionToStatement(str_replace(array(
"\n",
" ",
), '', var_export($query_str, TRUE)));
$query
->getElement()->multiline = 0;
$editor
->getReader()
->setPreserveArrayFormat(TRUE);
return $query;
}