CRM-15988 - Update generated examples
[civicrm-core.git] / api / v3 / examples / Grant / Get.php
index 8b4597cd4b5a4081df1b3ab149e871f770b37bec..ca51ac066070eb624b236015fb5f9248d091cd4b 100644 (file)
@@ -1,60 +1,68 @@
 <?php
 /**
- * Test Generated example of using grant get API
- * *
+ * Test Generated example demonstrating the Grant.get API.
+ *
+ * @return array
+ *   API result array
  */
-function grant_get_example(){
-$params = array(
-  'rationale' => 'Just Because',
-);
+function grant_get_example() {
+  $params = array(
+    'rationale' => 'Just Because',
+  );
 
-try{
-  $result = civicrm_api3('grant', 'get', $params);
-}
-catch (CiviCRM_API3_Exception $e) {
-  // handle error here
-  $errorMessage = $e->getMessage();
-  $errorCode = $e->getErrorCode();
-  $errorData = $e->getExtraParams();
-  return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
-}
+  try{
+    $result = civicrm_api3('Grant', 'get', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'error' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
 
-return $result;
+  return $result;
 }
 
 /**
- * Function returns array of result expected from previous function
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
  */
-function grant_get_expectedresult(){
+function grant_get_expectedresult() {
 
   $expectedResult = array(
-  'is_error' => 0,
-  'version' => 3,
-  'count' => 1,
-  'id' => 2,
-  'values' => array(
-      '2' => array(
-          'id' => '2',
-          'contact_id' => '4',
-          'application_received_date' => '20130728084957',
-          'decision_date' => '20130805000000',
-          'grant_type_id' => '1',
-          'amount_total' => '500.00',
-          'currency' => 'USD',
-          'rationale' => 'Just Because',
-          'status_id' => '1',
-        ),
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 1,
+    'values' => array(
+      '1' => array(
+        'id' => '1',
+        'contact_id' => '5',
+        'application_received_date' => '20130728084957',
+        'decision_date' => '20130805000000',
+        'grant_type_id' => '1',
+        'amount_total' => '500.00',
+        'currency' => 'USD',
+        'rationale' => 'Just Because',
+        'status_id' => '1',
+      ),
     ),
-);
+  );
 
   return $expectedResult;
 }
 
-
 /*
-* This example has been generated from the API test suite. The test that created it is called
-*
-* testGetGrant and can be found in
+* This example has been generated from the API test suite.
+* The test that created it is called "testGetGrant"
+* and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/GrantTest.php
 *
 * You can see the outcome of the API tests at
@@ -64,7 +72,7 @@ function grant_get_expectedresult(){
 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
 *
 * Browse the api on your own site with the api explorer
-* http://MYSITE.ORG/path/to/civicrm/api/explorer
+* http://MYSITE.ORG/path/to/civicrm/api
 *
 * Read more about testing here
 * http://wiki.civicrm.org/confluence/display/CRM/Testing