You are here

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

Creates a doc to be pushed to the PMP.

Parameters

array $values: Key/value pairs of data for the doc

Return value

object A PMP doc, built as a PHP object

File

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

Class

PMPAPIDrupal
@file

Code

function createDoc($values) {
  $values += array(
    'version' => '1.0',
    'lang' => 'en',
    'profile' => 'story',
    'attributes' => array(
      'published' => $this
        ->date(),
      'guid' => $this
        ->guid(),
    ),
    'items' => array(),
  );
  $doc = new stdClass();
  $doc->attributes = new stdClass();
  $doc->version = $values['version'];
  $profile = new stdClass();
  $profile->href = $this->base . '/profiles/' . $values['profile'];
  $doc->links->profile[] = $profile;
  if (!empty($values['alt_url'])) {
    $alt_url = new stdClass();
    $alt_url->href = $values['alt_url'];
    $doc->links->alternate[] = $alt_url;
  }
  foreach ($values['attributes'] as $k => $v) {
    $doc->attributes->{$k} = $v;
  }
  if (!empty($values['items'])) {
    $doc->links->item = $values['items'];
  }
  return $doc;
}