From a6f08a10c48018d5ed3a60082696ab380c355606 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 7 Apr 2021 12:53:01 +1200 Subject: [PATCH] [REF] Minor cleanup - remove unused variables This also removes the use of mergeHandler in place of this - which is usually an interim refactoring step when a function is moved --- CRM/Dedupe/MergeHandler.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/CRM/Dedupe/MergeHandler.php b/CRM/Dedupe/MergeHandler.php index 7d8ad7ca2f..5c40923ed9 100644 --- a/CRM/Dedupe/MergeHandler.php +++ b/CRM/Dedupe/MergeHandler.php @@ -380,21 +380,18 @@ class CRM_Dedupe_MergeHandler { * @throws \CRM_Core_Exception */ public function mergeLocations(): void { - $mergeHandler = $this; - $locBlocks = $mergeHandler->getLocationBlocksToMerge(); + $locBlocks = $this->getLocationBlocksToMerge(); $blocksDAO = []; - $migrationInfo = $mergeHandler->getMigrationInfo(); + $migrationInfo = $this->getMigrationInfo(); // @todo Handle OpenID (not currently in API). if (!empty($locBlocks)) { - $locationBlocks = CRM_Dedupe_Merger::getLocationBlockInfo(); - $primaryBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($mergeHandler->getToKeepID(), ['is_primary' => 1]); - $billingBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($mergeHandler->getToKeepID(), ['is_billing' => 1]); + $primaryBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($this->getToKeepID(), ['is_primary' => 1]); + $billingBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($this->getToKeepID(), ['is_billing' => 1]); foreach ($locBlocks as $name => $block) { $blocksDAO[$name] = ['delete' => [], 'update' => []]; - $daoName = 'CRM_Core_DAO_' . $locationBlocks[$name]['label']; $changePrimary = FALSE; $primaryDAOId = (array_key_exists($name, $primaryBlockIds)) ? array_pop($primaryBlockIds[$name]) : NULL; $billingDAOId = (array_key_exists($name, $billingBlockIds)) ? array_pop($billingBlockIds[$name]) : NULL; @@ -405,7 +402,7 @@ class CRM_Dedupe_MergeHandler { if (!$otherBlockId) { continue; } - $otherBlockDAO = $mergeHandler->copyDataToNewBlockDAO($otherBlockId, $name, $blkCount); + $otherBlockDAO = $this->copyDataToNewBlockDAO($otherBlockId, $name, $blkCount); // If we're deliberately setting this as primary then add the flag // and remove it from the current primary location (if there is one). @@ -414,7 +411,7 @@ class CRM_Dedupe_MergeHandler { if (!$changePrimary && $set_primary == "1") { $otherBlockDAO->is_primary = 1; if ($primaryDAOId) { - $removePrimaryDAO = $mergeHandler->getDAOForLocationEntity($name); + $removePrimaryDAO = $this->getDAOForLocationEntity($name); $removePrimaryDAO->id = $primaryDAOId; $removePrimaryDAO->is_primary = 0; $blocksDAO[$name]['update'][$primaryDAOId] = $removePrimaryDAO; @@ -433,7 +430,7 @@ class CRM_Dedupe_MergeHandler { // overwrite - need to delete block which belongs to main-contact. if (!empty($mainBlockId) && $values['is_replace']) { - $deleteDAO = $mergeHandler->getDAOForLocationEntity($name); + $deleteDAO = $this->getDAOForLocationEntity($name); $deleteDAO->id = $mainBlockId; $deleteDAO->find(TRUE); @@ -449,11 +446,11 @@ class CRM_Dedupe_MergeHandler { } $blocksDAO[$name]['update'][$otherBlockDAO->id] = $otherBlockDAO; } - $blocksDAO[$name]['update'] += $mergeHandler->getBlocksToUpdateForDeletedContact($name); + $blocksDAO[$name]['update'] += $this->getBlocksToUpdateForDeletedContact($name); } } - CRM_Utils_Hook::alterLocationMergeData($blocksDAO, $mergeHandler->getToKeepID(), $mergeHandler->getToRemoveID(), $migrationInfo); + CRM_Utils_Hook::alterLocationMergeData($blocksDAO, $this->getToKeepID(), $this->getToRemoveID(), $migrationInfo); foreach ($blocksDAO as $blockDAOs) { if (!empty($blockDAOs['update'])) { foreach ($blockDAOs['update'] as $blockDAO) { -- 2.25.1