Merge pull request #6500 from LevityNL/master
[civicrm-core.git] / api / v3 / Extension.php
index 2dfbe7728aa3b99e67ea6b1013f84ac4e241cd3a..2fe2bd7258f67b8e99f5ace29ef651de1efe5209 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.6                                                |
+ | CiviCRM version 4.7                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014                                |
+ | Copyright CiviCRM LLC (c) 2004-2015                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -29,7 +29,7 @@ define('API_V3_EXTENSION_DELIMITER', ',');
 
 
 /**
- * This api exposes CiviCRM extension.
+ * This provides an api interface for CiviCRM extension management.
  *
  * @package CiviCRM_APIv3
  */
@@ -97,9 +97,9 @@ function civicrm_api3_extension_upgrade() {
  *
  * @param array $params
  *   Input parameters.
- *                          - key: string, eg "com.example.myextension"
- *                          - keys: mixed; array of string, eg array("com.example.myextension1", "com.example.myextension2") or string with comma-delimited list
- *                            using 'keys' should be more performant than making multiple API calls with 'key'
+ *   - key: string, eg "com.example.myextension"
+ *   - keys: mixed; array of string, eg array("com.example.myextension1", "com.example.myextension2") or string with comma-delimited list
+ *     using 'keys' should be more performant than making multiple API calls with 'key'
  *
  * @return array
  *   API result
@@ -165,8 +165,8 @@ function civicrm_api3_extension_uninstall($params) {
  *
  * @param array $params
  *   Input parameters.
- *                          - key: string, eg "com.example.myextension"
- *                          - url: string eg "http://repo.com/myextension-1.0.zip"
+ *   - key: string, eg "com.example.myextension"
+ *   - url: string eg "http://repo.com/myextension-1.0.zip"
  *
  * @throws API_Exception
  * @return array
@@ -215,8 +215,8 @@ function civicrm_api3_extension_download($params) {
  *
  * @param array $params
  *   Input parameters.
- *                          - local: bool, whether to rescan local filesystem (default: TRUE)
- *                          - remote: bool, whether to rescan remote repository (default: TRUE)
+ *   - local: bool, whether to rescan local filesystem (default: TRUE)
+ *   - remote: bool, whether to rescan remote repository (default: TRUE)
  *
  * @return array
  *   API result
@@ -254,17 +254,19 @@ function civicrm_api3_extension_get($params) {
   $statuses = CRM_Extension_System::singleton()->getManager()->getStatuses();
   $mapper = CRM_Extension_System::singleton()->getMapper();
   $result = array();
+  $id = 0;
   foreach ($statuses as $key => $status) {
     //try {
     //  $info = (array) $mapper->keyToInfo($key);
     //} catch (CRM_Extension_Exception $e) {
     $info = array();
+    $info['id'] = $id++; // backward compatibility with indexing scheme
     $info['key'] = $key;
     //}
     $info['status'] = $status;
     $result[] = $info;
   }
-  return civicrm_api3_create_success($result);
+  return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', array('id', 'key', 'status'));
 }
 
 /**