本文整理匯總了PHP中CRM_Member_PseudoConstant::paymentInstrument方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Member_PseudoConstant::paymentInstrument方法的具體用法?PHP CRM_Member_PseudoConstant::paymentInstrument怎麽用?PHP CRM_Member_PseudoConstant::paymentInstrument使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Member_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Member_PseudoConstant::paymentInstrument方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validate
/**
* @return bool
*/
public function validate()
{
if (CRM_Utils_System::isNull($this->_value)) {
return TRUE;
}
switch ($this->_name) {
case 'contact_id':
// note: we validate extistence of the contact in API, upon
// insert (it would be too costlty to do a db call here)
return CRM_Utils_Rule::integer($this->_value);
case 'receive_date':
case 'cancel_date':
case 'receipt_date':
case 'thankyou_date':
return CRM_Utils_Rule::date($this->_value);
case 'non_deductible_amount':
case 'total_amount':
case 'fee_amount':
case 'net_amount':
return CRM_Utils_Rule::money($this->_value);
case 'trxn_id':
static $seenTrxnIds = array();
if (in_array($this->_value, $seenTrxnIds)) {
return FALSE;
} elseif ($this->_value) {
$seenTrxnIds[] = $this->_value;
return TRUE;
} else {
$this->_value = NULL;
return TRUE;
}
break;
case 'currency':
return CRM_Utils_Rule::currencyCode($this->_value);
case 'membership_type':
static $membershipTypes = NULL;
if (!$membershipTypes) {
$membershipTypes = CRM_Member_PseudoConstant::membershipType();
}
if (in_array($this->_value, $membershipTypes)) {
return TRUE;
} else {
return FALSE;
}
break;
case 'payment_instrument':
static $paymentInstruments = NULL;
if (!$paymentInstruments) {
$paymentInstruments = CRM_Member_PseudoConstant::paymentInstrument();
}
if (in_array($this->_value, $paymentInstruments)) {
return TRUE;
} else {
return FALSE;
}
break;
default:
break;
}
// check whether that's a valid custom field id
// and if so, check the contents' validity
if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($this->_name)) {
static $customFields = NULL;
if (!$customFields) {
$customFields = CRM_Core_BAO_CustomField::getFields('Membership');
}
if (!array_key_exists($customFieldID, $customFields)) {
return FALSE;
}
return CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $this->_value);
}
return TRUE;
}