From: Eileen McNaughton Date: Thu, 5 May 2022 11:12:58 +0000 (+1200) Subject: [Ref] Get rid of private deprecated legacy function X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=50c72d7f945f69ef7204ef86952067220b1e65f7;p=civicrm-core.git [Ref] Get rid of private deprecated legacy function It now doesn't have enough code to justify it's own function --- diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index e5e149a30a..fb8d5bacac 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -273,7 +273,6 @@ WHERE id IN ( $idString ) return; } $relationshipIds = []; - // create employee of relationship $duplicate = CRM_Contact_BAO_Relationship::checkDuplicateRelationship( [ 'contact_id_a' => $contactID, @@ -281,11 +280,19 @@ WHERE id IN ( $idString ) 'relationship_type_id' => $relationshipTypeID, ], $contactID, - // step 2 $employerID ); if (!$duplicate) { - $relationshipIds = [self::legacyCreateMultiple($relationshipTypeID, $employerID, $contactID)]; + $params = [ + 'is_active' => TRUE, + 'contact_check' => [$employerID => TRUE], + 'contact_id_a' => $contactID, + 'contact_id_b' => $employerID, + 'relationship_type_id' => $relationshipTypeID, + ]; + $relationship = CRM_Contact_BAO_Relationship::add($params); + CRM_Contact_BAO_Relationship::addRecent($params, $relationship); + $relationshipIds = [$relationship->id]; } // In case we change employer, clean previous employer related records. @@ -330,36 +337,6 @@ WHERE id IN ( $idString ) } } - /** - * Previously shared function in need of cleanup. - * - * Takes an associative array and creates a relationship object. - * - * @deprecated For single creates use the api instead (it's tested). - * For multiple a new variant of this function needs to be written and migrated to as this is a bit - * nasty - * - * @param int $relationshipTypeID - * @param int $organizationID - * @param int $contactID - * - * @return array - * @throws \CiviCRM_API3_Exception - */ - private static function legacyCreateMultiple(int $relationshipTypeID, int $organizationID, int $contactID): int { - $params = [ - 'is_active' => TRUE, - 'contact_check' => [$organizationID => TRUE], - 'contact_id_a' => $contactID, - 'contact_id_b' => $organizationID, - 'relationship_type_id' => $relationshipTypeID, - ]; - $relationship = CRM_Contact_BAO_Relationship::add($params); - CRM_Contact_BAO_Relationship::addRecent($params, $relationship); - - return $relationship->id; - } - /** * Create related memberships for current employer. *