You are here

function pmpapi_entity_insert in Public Media Platform API Integration 7

Implements hook_entity_insert().

File

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

Code

function pmpapi_entity_insert($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_insert('pmpapi_local_docs')
      ->fields(array(
      'entity_type' => $type,
      'entity_id' => $entity_id,
      'guid' => $entity->pmpapi_guid,
      'permissions' => $permissions,
    ))
      ->execute();
  }
}