X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2Fexamples%2FContribution%2FDelete.php;h=c22b1b102d2219623ce027337592c4b5ae5fc69f;hb=1d8ee3d65d4378d6e61eb9eb82cd3b33d70c502e;hp=5db15956624e3604565e497b3f13c0afcbdfbf68;hpb=992fa840d8ba027c64fc1a46c77d6b288337222b;p=civicrm-core.git diff --git a/api/v3/examples/Contribution/Delete.php b/api/v3/examples/Contribution/Delete.php index 5db1595662..c22b1b102d 100644 --- a/api/v3/examples/Contribution/Delete.php +++ b/api/v3/examples/Contribution/Delete.php @@ -1,50 +1,59 @@ 1, -); +function contribution_delete_example() { + $params = array( + 'id' => 1, + ); -try{ - $result = civicrm_api3('contribution', 'delete', $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('Contribution', 'delete', $params); + } + catch (CiviCRM_API3_Exception $e) { + // Handle error here. + $errorMessage = $e->getMessage(); + $errorCode = $e->getErrorCode(); + $errorData = $e->getExtraParams(); + return array( + 'is_error' => 1, + 'error_message' => $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 contribution_delete_expectedresult(){ +function contribution_delete_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' => 1, ), -); + ); return $expectedResult; } - /* -* This example has been generated from the API test suite. The test that created it is called -* -* testDeleteContribution and can be found in +* This example has been generated from the API test suite. +* The test that created it is called "testDeleteContribution" +* and can be found at: * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php * * You can see the outcome of the API tests at @@ -54,7 +63,7 @@ function contribution_delete_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