From f0cd48f06e244250c9f75895c0aab285cc229f4b Mon Sep 17 00:00:00 2001 From: Marek Isalski Date: Wed, 16 May 2018 18:02:56 +0100 Subject: [PATCH] add fulcrm_webhook_set_mapping function --- fulcrm_webhook.module | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fulcrm_webhook.module b/fulcrm_webhook.module index 7cebe7c..09b4181 100644 --- a/fulcrm_webhook.module +++ b/fulcrm_webhook.module @@ -46,6 +46,24 @@ function fulcrm_webhook_get_pk_for_entity_type( $entity_type, $entity_id, $fulcr return $result->fetchField(); } +function fulcrm_webhook_set_mapping( $entity_type, $bundle, $entity_id, $fulcrm_type, $fulcrm_pk ) { + db_merge( 'fulcrm_webhook_entity_mapping' ) + ->key( array( 'entity_type' => $entity_type, + 'bundle' => $bundle, + 'entity_id' => $entity_id, + ) ) + ->insertFields( array( 'fulcrm_type' => $fulcrm_type, + 'fulcrm_pk' => $fulcrm_pk, + 'entity_type' => $entity_type, + 'bundle' => $bundle, + 'entity_id' => $entity_id, + ) ) + ->updateFields( array( 'fulcrm_type' => $fulcrm_type, + 'fulcrm_pk' => $fulcrm_pk, + ) ) + ->execute(); +} + function fulcrm_webhook_load_entity_for_url( $url ) { $fulcrm_type = fulcrm_apiv2_url_to_type( $url ); $fulcrm_pk = fulcrm_apiv2_url_to_pk( $url );