*/
public $payment_instrument_id;
+ /**
+ * @var bool
+ */
+ private $_payNow;
+
/**
* Explicitly declare the form context.
*/
return 'create';
}
+ public function __get($name) {
+ if ($name === '_contributionID') {
+ CRM_Core_Error::deprecatedWarning('_contributionID is not a form property - use getContributionID()');
+ return $this->getContributionID();
+ }
+ return NULL;
+ }
+
/**
* Set variables up before form is built.
*
// Set title
if ($this->_mode && $this->_id) {
$this->_payNow = TRUE;
- $this->assign('payNow', $this->_payNow);
$this->setTitle(ts('Pay with Credit Card'));
}
elseif ($this->_values['is_template']) {
else {
$this->setPageTitle($this->_ppID ? ts('Pledge Payment') : ts('Contribution'));
}
+ $this->assign('payNow', $this->_payNow);
}
private function preProcessPledge(): void {
$smarty->assign('dataArray', $dataArray);
$smarty->assign('totalTaxAmount', $params['tax_amount'] ?? NULL);
}
-
- // lets store it in the form variable so postProcess hook can get to this and use it
- $form->_contributionID = $contribution->id;
}
// process soft credit / pcp params first
}
}
+ /**
+ * Retrieve a deprecated property, ensuring a deprecation notice is thrown.
+ *
+ * @param string $property
+ *
+ * @return mixed
+ * @throws \CRM_Core_Exception
+ */
+ protected function getDeprecatedProperty(string $property) {
+ return $this->form->getDeprecatedProperty($property);
+ }
+
}
\Civi::settings()->set('mailing_backend', $this->originalMailSetting);
}
+ /**
+ * Retrieve a deprecated property, ensuring a deprecation notice is thrown.
+ *
+ * @param string $property
+ *
+ * @return mixed
+ * @throws \CRM_Core_Exception
+ */
+ public function getDeprecatedProperty(string $property) {
+ try {
+ $this->form->$property;
+ }
+ catch (\Exception $e) {
+ $oldErrorLevel = error_reporting(0);
+ $value = $this->form->$property;
+ error_reporting($oldErrorLevel);
+ return $value;
+ }
+ throw new \CRM_Core_Exception('Deprecation should have been triggered');
+ }
+
}
/**
* Test the submit function on the contribution page.
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitWithNoteCreditCard(): void {
$this->submitContributionForm([
'contribution_status_id' => 1,
'note' => 'Super cool and interesting stuff',
] + $this->getCreditCardParams());
- $this->callAPISuccessGetCount('Contribution', ['contact_id' => $this->_individualId], 1);
+ $contribution = $this->callAPISuccessGetSingle('Contribution', ['contact_id' => $this->_individualId]);
$note = $this->callAPISuccessGetSingle('note', ['entity_table' => 'civicrm_contribution']);
$this->assertEquals('Super cool and interesting stuff', $note['note']);
+ $this->assertEquals($contribution['id'], $this->getDeprecatedProperty('_contributionID'));
}
/**