You are here

function pmpapi_pull_entity_insert in Public Media Platform API Integration 7

Implements hook_entity_insert().

File

pmpapi_pull/pmpapi_pull.module, line 205
Allows admins to pull content from the PMP API, and turn PMP docs into (locally-stored, independent) drupal entities.

Code

function pmpapi_pull_entity_insert($entity, $type) {
  if (!empty($entity->pmpapi_guid) && !empty($entity->pmpapi_pull)) {
    db_merge('pmpapi_pull_pulled_docs')
      ->key(array(
      'guid' => $entity->pmpapi_guid,
    ))
      ->fields(array(
      'guid' => $entity->pmpapi_guid,
      'changed' => REQUEST_TIME,
      'valid_from' => $entity->pmpapi_valid_from,
      'valid_to' => $entity->pmpapi_valid_to,
    ))
      ->execute();
  }
}