You are here

function PMPAPIDrupal::pull in Public Media Platform API Integration 7

Pulls from the PMP.

Parameters

object $node: PMP query parameters.

string $type: Query type (docs, profiles, users, etc.)

3 calls to PMPAPIDrupal::pull()
PMPAPIDrupal::report in classes/PMPAPIDrupal.php
Generates a basic report of PMP object.
PMPAPIDrupalPull::pullDoc in pmpapi_pull/classes/PMPAPIDrupalPull.php
Pulls a single doc from the PMP
PMPAPIDrupalPull::pullDocs in pmpapi_pull/classes/PMPAPIDrupalPull.php
Pulls docs from the PMP

File

classes/PMPAPIDrupal.php, line 128
Defines a class for PMP creation/transmission and retreival/parsing

Class

PMPAPIDrupal
@file

Code

function pull($options, $type = 'docs') {
  $this
    ->sdkInclude('CollectionDocJson');
  $key = $this
    ->cacheKey('docs', $options);
  $cache = $this
    ->cacheGet($key);
  if ($cache) {
    $this->query = $cache;
    $this->from_cache = TRUE;
  }
  else {
    try {
      $doc = $this
        ->getDoc();
      if ($doc) {
        $URN = "urn:collectiondoc:query:{$type}";
        $results = $doc
          ->query($URN)
          ->submit($options);
        $this->query->results = new stdClass();
        $this->query->results->json = $results;
        if (!empty($options['guid'])) {
          $this->query->results->docs[] = $results;
        }
        else {
          $this->query->results->docs = $results->items;
          $this->query->links = new stdClass();
          $this->query->links->navigation = $this
            ->flattenNavLinks($results->links->navigation);
        }
        $this
          ->cacheSet($key, $this->query);
      }
    } catch (Exception $e) {
      $message = t('Error querying the PMP. Message: @exception', array(
        '@exception' => $e
          ->getMessage(),
      ));
      drupal_set_message($message, 'warning');
      $this->errors['query'][] = $e
        ->getMessage();
    }
  }
}