You are here

function pmpapi_entity_update in Public Media Platform API Integration 7

Implements hook_entity_update().

File

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

Code

function pmpapi_entity_update($entity, $type) {
  if (!empty($entity->pmpapi_guid)) {
    list($entity_id, $vid, $bundle) = entity_extract_ids($type, $entity);
    $permissions = !empty($entity->pmpapi_permissions) ? serialize($entity->pmpapi_permissions) : NULL;
    db_merge('pmpapi_local_docs')
      ->key(array(
      'entity_type' => $type,
    ))
      ->key(array(
      'entity_id' => $entity_id,
    ))
      ->fields(array(
      'guid' => $entity->pmpapi_guid,
      'permissions' => $permissions,
    ))
      ->execute();
  }
}