You are here

function pmpapi_get_entity_from_guid in Public Media Platform API Integration 7

Finds a matching entity for a given GUID.

Parameters

string $guid: A PMP GUID

Return value

object/FALSE The entity, or NULL, if no entity exists.

1 call to pmpapi_get_entity_from_guid()
pmpapi_pull_check_valid_dates in pmpapi_pull/pmpapi_pull.module
Determines if the validity of a pulled doc has changed, and changes the corresponding node accordingly.

File

./pmpapi.module, line 537
Creates basic calls to the PMP API.

Code

function pmpapi_get_entity_from_guid($guid) {
  $entity = NULL;
  $doc = db_query('SELECT entity_id, entity_type FROM {pmpapi_local_docs} WHERE guid=:guid', array(
    ':guid' => $guid,
  ))
    ->fetchAssoc();
  if (!empty($doc['entity_id']) && !empty($doc['entity_type'])) {
    $entities = entity_load($doc['entity_type'], array(
      $doc['entity_id'],
    ));
    if (!empty($entities)) {
      $entity = array_shift($entities);
    }
  }
  return $entity;
}