Skip to content

Commit

Permalink
[REF] Minor simplification - do not use variable variables
Browse files Browse the repository at this point in the history
This is a minor readabilty improvement because it's awful. Much more could be done....
  • Loading branch information
eileenmcnaughton committed Mar 31, 2020
1 parent 8d557f6 commit 7f327c8
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions CRM/Campaign/BAO/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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);
}

Expand Down

0 comments on commit 7f327c8

Please sign in to comment.