Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] Remove unreachable handling #27192

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 13 additions & 36 deletions CRM/Contribute/Form/Contribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,18 +579,17 @@ public function buildQuickForm() {
$defaults['hidden_AdditionalDetail'] = 1;
}

$paneNames = [];
if (empty($this->_payNow)) {
$paneNames[ts('Additional Details')] = 'AdditionalDetail';
}

//Add Premium pane only if Premium is exists.
$dao = new CRM_Contribute_DAO_Product();
$dao->is_active = 1;
$allPanes = [ts('Additional Details') => $this->generatePane('AdditionalDetail', $defaults)];
//Add Premium pane only if Premium is exists.
$dao = new CRM_Contribute_DAO_Product();
$dao->is_active = 1;

if ($dao->find(TRUE) && empty($this->_payNow)) {
$paneNames[ts('Premium Information')] = 'Premium';
if ($dao->find(TRUE)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the payNow check is removed as I moved it inside the relevant IF

$allPanes[ts('Premium Information')] = $this->generatePane('Premium', $defaults);
}
}
$this->assign('allPanes', $allPanes ?: []);

$this->payment_instrument_id = $defaults['payment_instrument_id'] ?? $this->getDefaultPaymentInstrumentId();
CRM_Core_Payment_Form::buildPaymentForm($this, $this->_paymentProcessor, FALSE, TRUE, $this->payment_instrument_id);
Expand All @@ -614,13 +613,8 @@ public function buildQuickForm() {
}
$this->addPaymentProcessorSelect(FALSE, $buildRecurBlock);

foreach ($paneNames as $name => $type) {
$allPanes[$name] = $this->generatePane($type, $defaults);
}

$qfKey = $this->controller->_key;
$this->assign('qfKey', $qfKey);
$this->assign('allPanes', $allPanes);

$this->addFormRule(['CRM_Contribute_Form_Contribution', 'formRule'], $this);
$this->assign('formType', $this->_formType);
Expand Down Expand Up @@ -1380,8 +1374,7 @@ private function processFormContribution(
* This appears to mean 'there is a pane to show'.
*
* @param string $type
* Type of Pane - this is generally used to determine the function name used to build it
* - e.g CreditCard, AdditionalDetail
* Type of Pane - only options are AdditionalDetail or Premium
* @param array $defaults
*
* @return array
Expand All @@ -1395,16 +1388,9 @@ protected function generatePane($type, $defaults) {
$urlParams .= "&mode={$this->_mode}";
}

$open = 'false';
if ($type == 'CreditCard' ||
$type == 'DirectDebit'
) {
$open = 'true';
}

$pane = [
'url' => CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams),
'open' => $open,
'open' => 'false',
'id' => $type,
];

Expand All @@ -1415,18 +1401,9 @@ protected function generatePane($type, $defaults) {
$this->assign('showAdditionalInfo', TRUE);
$pane['open'] = 'true';
}

if ($type == 'CreditCard' || $type == 'DirectDebit') {
// @todo would be good to align tpl name with form name...
// @todo document why this hidden variable is required.
$this->add('hidden', 'hidden_' . $type, 1);
return $pane;
}
else {
$additionalInfoFormFunction = 'build' . $type;
CRM_Contribute_Form_AdditionalInfo::$additionalInfoFormFunction($this);
return $pane;
}
$additionalInfoFormFunction = 'build' . $type;
CRM_Contribute_Form_AdditionalInfo::$additionalInfoFormFunction($this);
return $pane;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public function testCreateSingleNowDated(): void {

$params = array_merge($billingParams, [
'qfKey' => '08ed21c7ca00a1f7d32fff2488596ef7_4454',
'hidden_CreditCard' => 1,
'is_recur' => 1,
'frequency_interval' => 1,
'frequency_unit' => 'month',
Expand Down Expand Up @@ -226,7 +225,6 @@ public function testCreateSinglePostDated(): void {

$params = [
'qfKey' => '00ed21c7ca00a1f7d555555596ef7_4454',
'hidden_CreditCard' => 1,
'billing_first_name' => $firstName,
'billing_middle_name' => '',
'billing_last_name' => $lastName,
Expand Down