X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2Fexamples%2FGrant%2FGet.php;h=ca51ac066070eb624b236015fb5f9248d091cd4b;hb=a828d7b823956a46f5a3cea184389c9b108f80ac;hp=15fbbf2bd09a83d97af58e44850c2f73278aeac6;hpb=2ac8532edbec25162652efef29faad9f41638ef5;p=civicrm-core.git diff --git a/api/v3/examples/Grant/Get.php b/api/v3/examples/Grant/Get.php index 15fbbf2bd0..ca51ac0660 100644 --- a/api/v3/examples/Grant/Get.php +++ b/api/v3/examples/Grant/Get.php @@ -1,60 +1,68 @@ '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' => 1, - 'values' => array( + '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', - ), + '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