From 7f327c88d653ac6ea8d693560aad22b32868b4fd Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 31 Mar 2020 16:38:23 +1300 Subject: [PATCH] [REF] Minor simplification - do not use variable variables This is a minor readabilty improvement because it's awful. Much more could be done.... --- CRM/Campaign/BAO/Campaign.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/CRM/Campaign/BAO/Campaign.php b/CRM/Campaign/BAO/Campaign.php index 4696f9e655f6..538eec049955 100644 --- a/CRM/Campaign/BAO/Campaign.php +++ b/CRM/Campaign/BAO/Campaign.php @@ -575,10 +575,10 @@ public static function addCampaign(&$form, $connectedCampaignId = NULL) { } $campaignDetails = self::getPermissionedCampaigns($connectedCampaignId, NULL, TRUE, TRUE, $appendDates); - $fields = ['campaigns', 'hasAccessCampaign', 'isCampaignEnabled']; - foreach ($fields as $fld) { - $$fld = $campaignDetails[$fld] ?? NULL; - } + + $campaigns = $campaignDetails['campaigns'] ?? NULL; + $hasAccessCampaign = $campaignDetails['hasAccessCampaign'] ?? NULL; + $isCampaignEnabled = $campaignDetails['isCampaignEnabled'] ?? NULL; $showAddCampaign = FALSE; if ($connectedCampaignId || ($isCampaignEnabled && $hasAccessCampaign)) { @@ -595,14 +595,12 @@ public static function addCampaign(&$form, $connectedCampaignId = NULL) { } //carry this info to templates. - $infoFields = [ - 'showAddCampaign', - 'hasAccessCampaign', - 'isCampaignEnabled', + $campaignInfo = [ + 'showAddCampaign' => $showAddCampaign, + 'hasAccessCampaign' => $hasAccessCampaign, + 'isCampaignEnabled' => $isCampaignEnabled, ]; - foreach ($infoFields as $fld) { - $campaignInfo[$fld] = $$fld; - } + $form->assign('campaignInfo', $campaignInfo); }