You are here

function pmpapi_push_push_entity_to_pmp in Public Media Platform API Integration 7

Pushes an entity to the PMP API.

Parameters

object $entity: Any drupal entity object

string $type: The type of entity (node, file, etc.)

$profile string: The type of PMP profile that will be created

array $mapping: A mapping of entity fields to PMP profile attributes (etc.)

2 calls to pmpapi_push_push_entity_to_pmp()
pmpapi_push_entity_insert in pmpapi_push/pmpapi_push.module
Implements hook_entity_insert().
pmpapi_push_entity_update in pmpapi_push/pmpapi_push.module
Implements hook_entity_update().

File

pmpapi_push/pmpapi_push.module, line 119
Maps drupal entities to MPM profiles, and pushes them to the PMP API.

Code

function pmpapi_push_push_entity_to_pmp($entity, $type, $profile, $mapping) {
  $pmp = new PMPAPIDrupalPush();
  if ($pmp
    ->pushEntity($entity, $type, $profile, $mapping)) {
    $wrapper = entity_metadata_wrapper($type, $entity);
    $bundle_name = $wrapper
      ->getBundle();
    $label = $wrapper
      ->label();
    drupal_set_message(t('@bundle_name %label was successfully pushed to the PMP API.', array(
      '@bundle_name' => $bundle_name,
      '%label' => $label,
    )));
  }
}