From 2604efa9c75b13cc72ce7a60fc43b526c3431c40 Mon Sep 17 00:00:00 2001 From: Marek Isalski Date: Mon, 14 Mar 2016 10:39:45 +0100 Subject: [PATCH] add fulcrm_apiv2_url_to_type and fulcrm_apiv2_url_to_pk --- fulcrm_apiv2.module | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fulcrm_apiv2.module b/fulcrm_apiv2.module index 9f43045..a963ba8 100644 --- a/fulcrm_apiv2.module +++ b/fulcrm_apiv2.module @@ -44,6 +44,16 @@ function fulcrm_apiv2_prevent_loop( $headers ) { return true; } +function fulcrm_apiv2_url_to_type( $url ) { + preg_match( '/https:\/\/[^\/]+\/api\/v2\/([a-z_0-9]+)\/([0-9]+)?\//', $url, $matches ); + return $matches[ 1 ]; +} + +function fulcrm_apiv2_url_to_pk( $url ) { + preg_match( '/https:\/\/[^\/]+\/api\/v2\/([a-z_0-9]+)\/([0-9]+)?\//', $url, $matches ); + return intval( $matches[ 2 ] ); +} + function fulcrm_apiv2_http( $method, $object = null, $data = null, $query = null ) { $url = null;