function hook_pmpapi_push_entity_ok_to_push in Public Media Platform API Integration 7
Act on test to determine if entity should be pushed.
Parameters
object $entity: Any drupal entity object
string $type: The type of entity (node, file, etc.)
1 function implements hook_pmpapi_push_entity_ok_to_push()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- pmpapi_pull_pmpapi_push_entity_ok_to_push in pmpapi_pull/pmpapi_pull.module 
- Implements hook_pmpapi_push_entity_ok_to_push().
1 invocation of hook_pmpapi_push_entity_ok_to_push()
- pmpapi_push_entity_ok_to_push in pmpapi_push/pmpapi_push.module 
- Determines if an entity should be pushed to the PMP API.
File
- pmpapi_push/pmpapi_push.api.php, line 28 
- Hooks provided by the PMPAPI push module.
Code
function hook_pmpapi_push_entity_ok_to_push($entity, $type) {
  // If entity is a node of type 'story', only push if it has a particular program
  // program related to it (via entityreference)
  // In other words, push stories only from a certain show
  $machine_name = 'story';
  //machine name of content type
  $field = 'field_program';
  // machine name of program entityrefernce field
  $fishin_nid = 2;
  // nid of "Fishin' with Dave"
  if ($type == 'node' && $entity->type == $machine_name) {
    $language = isset($entity->language) ? $entity->language : LANGUAGE_NONE;
    $field_items = field_get_items($type, $entity, $field, $language);
    foreach ($field_items as $field_item) {
      if ($field_item['target_id'] == $fishin_nid) {
        return TRUE;
      }
    }
    // If we fall through to here, we can assume it's a story, but not a
    // "Fishin' with Dave" story, so cancel push.
    // NB: If you want to cancel push, MAKE SURE that you return an explicit FALSE
    // (rather than just falling out of the function)
    return FALSE;
  }
  // The default return will likely be TRUE
  return TRUE;
}