Skip to content

Commit

Permalink
Merge pull request civicrm#28676 from eileenmcnaughton/init
Browse files Browse the repository at this point in the history
Remove deprecated function `initSet`
  • Loading branch information
mattwire authored Dec 18, 2023
2 parents e0367b9 + 418c6c5 commit e2ff216
Showing 1 changed file with 0 additions and 96 deletions.
96 changes: 0 additions & 96 deletions CRM/Price/BAO/PriceSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,102 +535,6 @@ public static function getOnlyPriceFieldValueID(array $priceSet) {
return (int) implode('_', array_keys($priceSet['fields'][$priceFieldID]['options']));
}

/**
* Initiate price set such that various non-BAO things are set on the form.
*
* This function is not really a BAO function so the location is misleading.
*
* @param CRM_Core_Form $form
* Form entity id.
* @param string $entityTable
* @param bool $doNotIncludeExpiredFields
* @param int $priceSetId
* Price Set ID
*
* @throws \CRM_Core_Exception
* @deprecated in CiviCRM 5.58, will be removed around CiviCRM 5.70.
*/
public static function initSet(&$form, $entityTable = 'civicrm_event', $doNotIncludeExpiredFields = FALSE, $priceSetId = NULL) {
CRM_Core_Error::deprecatedFunctionWarning('no alternative');

// get price info
if ($priceSetId) {
if ($form->_action & CRM_Core_Action::UPDATE) {
$entityId = $entity = NULL;

switch ($entityTable) {
case 'civicrm_event':
$entity = 'participant';
if (in_array(CRM_Utils_System::getClassName($form), ['CRM_Event_Form_Participant', 'CRM_Event_Form_Task_Register'])) {
$entityId = $form->_id;
}
else {
$entityId = $form->_participantId;
}
break;

case 'civicrm_contribution_page':
case 'civicrm_contribution':
$entity = 'contribution';
$entityId = $form->_id;
break;
}

if ($entityId && $entity) {
$form->_values['line_items'] = CRM_Price_BAO_LineItem::getLineItems($entityId, $entity);
}
$required = FALSE;
}
else {
$required = TRUE;
}

$form->_priceSetId = $priceSetId;
$priceSet = self::getSetDetail($priceSetId, $required, $doNotIncludeExpiredFields);
$form->_priceSet = $priceSet[$priceSetId] ?? NULL;
$form->_values['fee'] = $form->_priceSet['fields'] ?? NULL;

//get the price set fields participant count.
if ($entityTable === 'civicrm_event') {
//get option count info.
$form->_priceSet['optionsCountTotal'] = self::getPricesetCount($priceSetId);
if ($form->_priceSet['optionsCountTotal']) {
$optionsCountDetails = [];
if (!empty($form->_priceSet['fields'])) {
foreach ($form->_priceSet['fields'] as $field) {
foreach ($field['options'] as $option) {
$count = $option['count'] ?? 0;
$optionsCountDetails['fields'][$field['id']]['options'][$option['id']] = $count;
}
}
}
$form->_priceSet['optionsCountDetails'] = $optionsCountDetails;
}

//get option max value info.
$optionsMaxValueTotal = 0;
$optionsMaxValueDetails = [];

if (!empty($form->_priceSet['fields'])) {
foreach ($form->_priceSet['fields'] as $field) {
foreach ($field['options'] as $option) {
$maxVal = $option['max_value'] ?? 0;
$optionsMaxValueDetails['fields'][$field['id']]['options'][$option['id']] = $maxVal;
$optionsMaxValueTotal += $maxVal;
}
}
}

$form->_priceSet['optionsMaxValueTotal'] = $optionsMaxValueTotal;
if ($optionsMaxValueTotal) {
$form->_priceSet['optionsMaxValueDetails'] = $optionsMaxValueDetails;
}
}
$form->set('priceSetId', $form->_priceSetId);
$form->set('priceSet', $form->_priceSet);
}
}

/**
* Get line item purchase information.
*
Expand Down

0 comments on commit e2ff216

Please sign in to comment.