You are here

function LTIToolProviderOAuthDataStore::lookup_consumer in LTI Tool Provider 7

Find a consumer matching a key.

Parameters

string $consumer_key: A consumer key to lookup.

Return value

OAuthConsumer The corresponding consumer entity.

Overrides OAuthDataStore::lookup_consumer

File

./LTIToolProviderOAuthDataStore.class.php, line 19
Contains LTIToolProviderOAuthDataStore.

Class

LTIToolProviderOAuthDataStore
@file Contains LTIToolProviderOAuthDataStore.

Code

function lookup_consumer($consumer_key) {
  $query = new EntityFieldQuery();
  $result = $query
    ->entityCondition('entity_type', 'lti_tool_provider_consumer')
    ->propertyCondition('lti_tool_provider_consumer_key', $consumer_key, '=')
    ->addMetaData('account', user_load(1))
    ->execute();
  if (isset($result['lti_tool_provider_consumer'])) {
    $consumer_ids = array_keys($result['lti_tool_provider_consumer']);
    $consumers = entity_load('lti_tool_provider_consumer', $consumer_ids);
    $consumer_entity = reset($consumers);
    $consumer = new OAuthConsumer($consumer_key, $consumer_entity->lti_tool_provider_consumer_secret, NULL);
  }
  else {
    $consumer = new OAuthConsumer($consumer_key, NULL, NULL);
  }
  return $consumer;
}