You are here

function miniorange_oauth_clientController::getnestedattribute in OAuth2 Login 8

This function is used to get some specific values from the resource

1 call to miniorange_oauth_clientController::getnestedattribute()
miniorange_oauth_clientController::miniorange_oauth_client_mo_login in src/Controller/miniorange_oauth_clientController.php

File

src/Controller/miniorange_oauth_clientController.php, line 333
Contains \Drupal\miniorange_oauth_client\Controller\DefaultController.

Class

miniorange_oauth_clientController

Namespace

Drupal\oauth2_login\Controller

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 self::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];
      }
    }
  }
}