You are here

function getnestedattribute in Drupal OAuth & OpenID Connect Login - OAuth2 Client SSO Login 7

This function gets the value of an attribute from the user resource

1 call to getnestedattribute()
test_config in ./miniorange_oauth_client.module

File

./miniorange_oauth_client.module, line 351

Code

function getnestedattribute($resource, $key) {
  if (empty($key)) {
    return "";
  }
  $keys = explode(".", $key);
  $currentkey = "";
  if (sizeof($keys) > 1) {
    $currentkey = $keys[0];
    if (isset($resource[$currentkey])) {
      return getnestedattribute($resource[$currentkey], str_replace($currentkey . ".", "", $key));
    }
  }
  else {
    $currentkey = $keys[0];
    if (isset($resource[$currentkey])) {
      if (is_array($resource[$currentkey])) {
        $resource = $resource[$currentkey];
        return $resource[0];
      }
      else {
        return $resource[$currentkey];
      }
    }
  }
}