You are here

function wf_crm_webform_base::__get in Webform CiviCRM Integration 7.4

Same name and namespace in other branches
  1. 7.5 includes/wf_crm_webform_base.inc \wf_crm_webform_base::__get()

Magic method to retrieve otherwise inaccessible properties

Parameters

$name:

Return value

mixed

Throws

Exception

File

includes/wf_crm_webform_base.inc, line 45

Class

wf_crm_webform_base
Class wf_crm_webform_base

Code

function __get($name) {
  switch ($name) {
    case 'payment_processor':
      $payment_processor_id = wf_crm_aval($this->data, 'contribution:1:contribution:1:payment_processor_id');
      if ($payment_processor_id && !$this->_payment_processor) {
        $this->_payment_processor = wf_civicrm_api('payment_processor', 'getsingle', array(
          'id' => $payment_processor_id,
        ));
      }
      return $this->_payment_processor;
    case 'contribution_page':
      $contribution_page_id = wf_crm_aval($this->data, 'contribution:1:contribution:1:contribution_page_id');
      if ($contribution_page_id && !$this->_contribution_page) {
        $this->_contribution_page = wf_civicrm_api('contribution_page', 'getsingle', array(
          'id' => $contribution_page_id,
        ));
      }
      return $this->_contribution_page;
    case 'tax_rate':
      $taxSettings = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'contribution_invoice_settings');
      if (is_array($taxSettings) && !empty($taxSettings['invoicing'])) {
        if ($this->contribution_page) {

          // tax integration
          $taxRates = CRM_Core_PseudoConstant::getTaxRates();
          $this->_tax_rate = isset($taxRates[$this->_contribution_page['financial_type_id']]) ? $taxRates[$this->_contribution_page['financial_type_id']] : NULL;
        }
        return $this->_tax_rate;
      }
      return NULL;
    case 'civicrm_version':
      return CRM_Utils_System::version();
    default:
      throw new Exception('Unknown property');
  }
}