You are here

function _brightcove_create_client in Brightcove Video Connect 7.7

Same name and namespace in other branches
  1. 7.6 brightcove.module \_brightcove_create_client()

Parameters

Entity $client_entity:

Return value

\Brightcove\API\Client

1 call to _brightcove_create_client()
brightcove_create_classes in ./brightcove.module

File

./brightcove.module, line 2530
Brightcove module is an integration layer between any modules using Brightcove API. It makes all necessary checks for the API and makes settings available to the user.

Code

function _brightcove_create_client(Entity $client_entity) {
  $cache =& drupal_static(__FUNCTION__, []);
  if (!empty($cache[$client_entity->bcid]) && $cache[$client_entity->bcid]['auth_time'] + BRIGHTCOVE_AUTHORIZATION_INTERVAL >= time()) {
    return $cache[$client_entity->bcid]['client'];
  }
  brightcove_load_lib();
  brightcove_try(function () use ($client_entity, &$cache) {
    $client_id = $client_entity->client_id;
    $client_secret = $client_entity->client_secret;
    $cache[$client_entity->bcid]['client'] = \Brightcove\API\Client::authorize($client_id, $client_secret);
    $cache[$client_entity->bcid]['auth_time'] = time();
  });
  return isset($cache[$client_entity->bcid]['client']) ? $cache[$client_entity->bcid]['client'] : NULL;
}