You are here

function services_admin_browse_test_unserialize_args in Services 7

Same name and namespace in other branches
  1. 5 services_admin_browse.inc \services_admin_browse_test_unserialize_args()
  2. 6 services_admin_browse.inc \services_admin_browse_test_unserialize_args()
  3. 6.2 services_admin_browse.inc \services_admin_browse_test_unserialize_args()
1 call to services_admin_browse_test_unserialize_args()
services_admin_browse_test_submit in ./services_admin_browse.inc

File

./services_admin_browse.inc, line 165
@author Services Dev Team

Code

function services_admin_browse_test_unserialize_args($values, $formats) {
  $method = services_method_get(arg(4));
  $noskip = FALSE;

  // Convert args
  for ($c = count($method['#args']) - 1; $c >= 0; $c--) {
    $arg = $method['#args'][$c];
    $value = $values[$c];

    // Remove empty values from end of array
    // Once we find a value, we can no longer skip
    if (!is_numeric($value) && empty($value) && !$noskip) {
      continue;
    }
    $noskip = TRUE;
    switch ($formats[$c]) {
      case 'cdel':
        if (empty($value)) {
          $return[$c] = NULL;
        }
        else {
          $return[$c] = split(',', $value);
        }
        break;
      case 'json':
        if (empty($value)) {
          $return[$c] = NULL;
        }
        else {
          $return[$c] = json_decode($value, $arg['#type'] === 'array');
        }
        break;
      case 'sphp':
        if (empty($value)) {
          $return[$c] = NULL;
        }
        else {
          $return[$c] = unserialize($value);
        }
        break;
      default:
        $return[$c] = $value;
    }
  }
  if ($return) {
    ksort($return);
  }
  return $return;
}