Merge pull request #139 from lcdservices/master
[civicrm-core.git] / api / v3 / Generic / Update.php
1 <?php
2 // $Id$
3
4 /**
5 * Our original intention was not to have an update action. However, we wound up having
6 * to retain it for backward compatibility. The only difference between update and create
7 * is that update will throw an error if id is not a number
8 * CRM-10908
9 * @param $apiRequest an array with keys:
10 * - entity: string
11 * - action: string
12 * - version: string
13 * - function: callback (mixed)
14 * - params: array, varies
15 */
16 function civicrm_api3_generic_update($apiRequest) {
17
18 if (!array_key_exists('id', $apiRequest['params']) ||
19 empty($apiRequest['params']['id']) ||
20 !is_numeric($apiRequest['params']['id'])) {
21 throw new api_Exception("Mandatory parameter missing `id`", 2000);
22 }
23 return civicrm_api($apiRequest['entity'], 'create', $apiRequest['params']);
24 }
25