Commit 8cd009ea authored by Botto's avatar Botto Committed by Ev Maslovskiy
Browse files

Issue #2752973 by Botto, Spleshka: Call hook to handle the deletion step in sync

parent ac8fc182
Loading
Loading
Loading
Loading
+14 −0
Changes for sharepoint_rest.api.php: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -45,3 +45,17 @@ function hook_sharepoint_rest_pull_changes_filter($change) {
  $filter .= ' and External eq 1';
  return $filter;
}

/**
 * Is invoked when pulling from SP and the item has been deleted.
 * 
 * @param $map_entity object
 *   The mapping entity between SP and DP
 */
function hook_sharepoint_rest_pull_entity_delete($map_entity) {
  $dp_entity = entity_load_single($map_entity->entity_type, $map_entity->entity_id);
  $dp_entity->status = 0;
  // Set a flag to know it was saved from sync
  $dp_entity->sharepoint_migrate_flag = TRUE;
  entity_save($map_entity->entity_type, $dp_entity);
}
+1 −3
Changes for sharepoint_rest.cron.inc: 1 added line, 3 removed lines.
Original line number Diff line number Diff line
@@ -52,9 +52,7 @@ function sharepoint_rest_pull_sharepoint_changes() {
        $entities = sharepoint_rest_api_get_map_by_sp_item($sp_list_type, $change->ItemId);
        if (!empty($entities)) {
          foreach ($entities as $drupal_entity) {
            $entity = entity_load_single($drupal_entity->entity_type, $drupal_entity->entity_id);
            $entity->status = 0;
            entity_save($drupal_entity->entity_type, $entity);
            module_invoke_all('sharepoint_rest_pull_entity_delete', $drupal_entity);
          }
        }
      }