You are here

public static function AcquiaDAM_API::getClient in Media: Acquia DAM 7

Get an AcquiaDAM_Client client instance.

Return value

AcquiaDAM_Client A client object.

5 calls to AcquiaDAM_API::getClient()
AcquiaDAM_Assets_AbstractAsset::getClient in src/AcquiaDAM/AcquiaDAM_Assets_AbstractAsset.inc
Gets the client object for use.
AcquiaDAM_Search::__construct in src/AcquiaDAM/AcquiaDAM_Search.inc
AcquiaDAM_Search constructor.
media_acquiadam_browser_choose_asset_form in modules/media_acquiadam_browser/includes/media_acquiadam_browser.forms.inc
Acquia DAM browser form.
media_acquiadam_deauth_page in includes/media_acquiadam.pages.inc
Clears the current user's authentication token.
media_acquiadam_get_helper in includes/media_acquiadam.helpers.inc
Asset/folder get helper that can load and store assets to cache.

File

src/AcquiaDAM/AcquiaDAM_API.inc, line 18

Class

AcquiaDAM_API
AcquiaDAM_API helper class.

Code

public static function getClient($key = NULL) {
  $client_mode = variable_get('media_acquiadam_client_mode', 'mixed');
  if (empty($key) && 'mixed' == $client_mode) {
    $key = 'acquiadam-server-auth';
  }
  elseif (empty($key) && 'background' == $client_mode) {
    $key = 'acquiadam-user-auth';
  }

  // Reuse the same client instance during the request.
  static $client;
  if (empty($client[$key])) {
    try {
      $oauth2_client = oauth2_client_load($key);
      $client[$key] = new AcquiaDAM_Client($oauth2_client);
    } catch (Exception $x) {
      watchdog_exception('AcquiaDAM_API', $x);
    }
  }
  return $client[$key];
}