From: Tim Otten Date: Mon, 24 Mar 2014 22:47:04 +0000 (-0700) Subject: CRM-14370 - API Kernel - Extract createRequest() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=61c8f96f1349657f1d0afde21a159ce89562cab9;p=civicrm-core.git CRM-14370 - API Kernel - Extract createRequest() --- diff --git a/Civi/API/Kernel.php b/Civi/API/Kernel.php index ed13ecb280..2ab5acc6b6 100644 --- a/Civi/API/Kernel.php +++ b/Civi/API/Kernel.php @@ -31,7 +31,6 @@ use Civi\API\Event\PrepareEvent; use Civi\API\Event\ExceptionEvent; use Civi\API\Event\RespondEvent; - /** * * @package Civi @@ -67,13 +66,7 @@ class Kernel { * @return array|int */ public function run($entity, $action, $params, $extra) { - $apiRequest = array(); - $apiRequest['entity'] = \CRM_Utils_String::munge($entity); - $apiRequest['action'] = \CRM_Utils_String::munge($action); - $apiRequest['version'] = civicrm_get_api_version($params); - $apiRequest['params'] = $params; - $apiRequest['extra'] = $extra; - $apiRequest['fields'] = NULL; + $apiRequest = $this->createRequest($entity, $action, $params, $extra); try { if (!is_array($params)) { @@ -129,6 +122,26 @@ class Kernel { } + /** + * Create a formatted/normalized request object. + * + * @param string $entity + * @param string $action + * @param array $params + * @param mixed $extra + * @return array the request descriptor + */ + public function createRequest($entity, $action, $params, $extra) { + $apiRequest = array(); + $apiRequest['entity'] = \CRM_Utils_String::munge($entity); + $apiRequest['action'] = \CRM_Utils_String::munge($action); + $apiRequest['version'] = civicrm_get_api_version($params); + $apiRequest['params'] = $params; + $apiRequest['extra'] = $extra; + $apiRequest['fields'] = NULL; + return $apiRequest; + } + public function boot() { require_once ('api/v3/utils.php'); require_once 'api/Exception.php';