Merge pull request #14928 from lcdservices/dev-core-1158
[civicrm-core.git] / api / v3 / Pledge.php
index 596c10655f2cd63fa148fbec29d2f4c08285b650..25f661502e103b972ed68eca37ac59541ebe13fc 100644 (file)
@@ -1,27 +1,11 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.7                                                |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2017                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
+ | Copyright CiviCRM LLC. All rights reserved.                        |
  |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
  +--------------------------------------------------------------------+
  */
 
@@ -55,9 +39,9 @@ function civicrm_api3_pledge_create($params) {
  */
 function civicrm_api3_pledge_delete($params) {
   if (CRM_Pledge_BAO_Pledge::deletePledge($params['id'])) {
-    return civicrm_api3_create_success(array(
+    return civicrm_api3_create_success([
       'id' => $params['id'],
-    ), $params, 'Pledge', 'delete');
+    ], $params, 'Pledge', 'delete');
   }
   else {
     return civicrm_api3_create_error('Could not delete pledge');
@@ -71,7 +55,7 @@ function civicrm_api3_pledge_delete($params) {
  */
 function _civicrm_api3_pledge_delete_spec(&$params) {
   // set as not required as pledge_id also acceptable & no either/or std yet
-  $params['id']['api.aliases'] = array('pledge_id');
+  $params['id']['api.aliases'] = ['pledge_id'];
 }
 
 /**
@@ -80,15 +64,15 @@ function _civicrm_api3_pledge_delete_spec(&$params) {
  * @param array $params
  */
 function _civicrm_api3_pledge_get_spec(&$params) {
-  $params['next_pay_date'] = array(
+  $params['next_pay_date'] = [
     'name' => 'next_pay_date',
     'type' => 12,
     'title' => 'Pledge Made',
     'api.filter' => 0,
     'api.return' => 1,
-  );
+  ];
   $params['pledge_is_test']['api.default'] = 0;
-  $params['pledge_financial_type_id']['api.aliases'] = array('contribution_type_id', 'contribution_type');
+  $params['pledge_financial_type_id']['api.aliases'] = ['contribution_type_id', 'contribution_type'];
 
 }
 
@@ -99,13 +83,13 @@ function _civicrm_api3_pledge_get_spec(&$params) {
  */
 function _civicrm_api3_pledge_create_spec(&$params) {
 
-  $required = array('contact_id', 'amount', 'installments', 'start_date', 'financial_type_id');
+  $required = ['contact_id', 'amount', 'installments', 'start_date', 'financial_type_id'];
   foreach ($required as $required_field) {
     $params[$required_field]['api.required'] = 1;
   }
   // @todo this can come from xml
-  $params['amount']['api.aliases'] = array('pledge_amount');
-  $params['financial_type_id']['api.aliases'] = array('contribution_type_id', 'contribution_type');
+  $params['amount']['api.aliases'] = ['pledge_amount'];
+  $params['financial_type_id']['api.aliases'] = ['contribution_type_id', 'contribution_type'];
 }
 
 /**
@@ -122,7 +106,7 @@ function civicrm_api3_pledge_get($params) {
 
   list($dao, $query) = _civicrm_api3_get_query_object($params, $mode, 'Pledge');
 
-  $pledge = array();
+  $pledge = [];
   while ($dao->fetch()) {
     $pledge[$dao->pledge_id] = $query->store($dao);
   }
@@ -134,7 +118,7 @@ function civicrm_api3_pledge_get($params) {
  * Set default to not return test params.
  */
 function _civicrm_api3_pledge_get_defaults() {
-  return array('pledge_test' => 0);
+  return ['pledge_test' => 0];
 }
 
 /**