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

Simplify class inheritance #23121

Merged
merged 1 commit into from
Apr 7, 2022
Merged
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
Simplify class inheritance
CRM_Contribute_Import_Parser_Contribution is the only class in our universe to
extend CRM_Contribute_Import_Parser and this class only adds confusion to the
mix as functions are 'distributed' between them. This removes the inheritance,
leaving only the constant that is still used in the now-deprecated class
eileenmcnaughton committed Apr 6, 2022
commit 8dc9763a2d9de8cdffa311fc0f2cb7ff8572ef94
2 changes: 1 addition & 1 deletion .toxic.json
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@
"CRM_Contribute_Form_Contribution_Main::formRule()": "toxicAlert",
"CRM_Contribute_Form_Contribution_Main::submit()": "toxicAlert",
"CRM_Contribute_Form_Task_Invoice::printPDF()": "toxicAlert",
"CRM_Contribute_Import_Parser::run()": "toxicAlert",
"CRM_Contribute_Import_Parser_Contribution::run()": "toxicAlert",
"CRM_Core_BAO_ActionScheduleTest::setUp()": "toxicAlert",
"CRM_Core_BAO_CustomField::formatCustomField()": "toxicAlert",
"CRM_Core_BAO_CustomGroup::getTree()": "toxicAlert",
12 changes: 6 additions & 6 deletions CRM/Contribute/Import/Form/Preview.php
Original file line number Diff line number Diff line change
@@ -54,17 +54,17 @@ public function preProcess() {
}

if ($invalidRowCount) {
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($conflictRowCount) {
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

if ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}

@@ -160,11 +160,11 @@ public function postProcess() {
fclose($fd);

$this->set('errorFile', $errorFile);
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Import_Parser::ERROR . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Import_Parser::CONFLICT . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadConflictRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
}
8 changes: 4 additions & 4 deletions CRM/Contribute/Import/Form/Summary.php
Original file line number Diff line number Diff line change
@@ -35,13 +35,13 @@ public function preProcess() {
$invalidRowCount = $this->get('invalidRowCount');
$invalidSoftCreditRowCount = $this->get('invalidSoftCreditRowCount');
if ($invalidSoftCreditRowCount) {
$urlParams = 'type=' . CRM_Contribute_Import_Parser::SOFT_CREDIT_ERROR . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT_ERROR . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadSoftCreditErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
$validSoftCreditRowCount = $this->get('validSoftCreditRowCount');
$invalidPledgePaymentRowCount = $this->get('invalidPledgePaymentRowCount');
if ($invalidPledgePaymentRowCount) {
$urlParams = 'type=' . CRM_Contribute_Import_Parser::PLEDGE_PAYMENT_ERROR . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Contribute_Import_Parser_Contribution::PLEDGE_PAYMENT_ERROR . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadPledgePaymentErrorRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
$validPledgePaymentRowCount = $this->get('validPledgePaymentRowCount');
@@ -50,11 +50,11 @@ public function preProcess() {
$onDuplicate = $this->get('onDuplicate');
$mismatchCount = $this->get('unMatchCount');
if ($duplicateRowCount > 0) {
$urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Import_Parser::DUPLICATE . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadDuplicateRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
elseif ($mismatchCount) {
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser';
$urlParams = 'type=' . CRM_Import_Parser::NO_MATCH . '&parser=CRM_Contribute_Import_Parser_Contribution';
$this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams));
}
else {
667 changes: 0 additions & 667 deletions CRM/Contribute/Import/Parser.php

This file was deleted.

662 changes: 655 additions & 7 deletions CRM/Contribute/Import/Parser/Contribution.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ public function testImportParserWithSoftCreditsByExternalIdentifier(string $thou
];
$mapperSoftCredit = [NULL, NULL, NULL, 'external_identifier'];
$mapperSoftCreditType = [NULL, NULL, NULL, '1'];
$this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Contribute_Import_Parser::SOFT_CREDIT, $mapperSoftCredit, NULL, $mapperSoftCreditType);
$this->runImport($values, CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Contribute_Import_Parser_Contribution::SOFT_CREDIT, $mapperSoftCredit, NULL, $mapperSoftCreditType);

$contributionsOfMainContact = Contribution::get()->addWhere('contact_id', '=', $contact1Id)->execute();
$this->assertCount(1, $contributionsOfMainContact, 'Contribution not added for primary contact');