Skip to content

Commit

Permalink
Merge pull request #24693 from eileenmcnaughton/badge
Browse files Browse the repository at this point in the history
dev/core#3829 Fix semi-recent regression on event badge
  • Loading branch information
demeritcowboy authored Oct 11, 2022
2 parents 8e6f6aa + b9c62cc commit b271739
Show file tree
Hide file tree
Showing 5 changed files with 4,302 additions and 4,307 deletions.
16 changes: 9 additions & 7 deletions CRM/Badge/BAO/Badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function createLabels($participants, &$layoutInfo) {
* @return array
* row with meta data
*/
public static function formatLabel(&$row, &$layout) {
public static function formatLabel(array $row, array $layout): array {
$formattedRow = ['labelFormat' => $layout['label_format_name']];
$formattedRow['labelTitle'] = $layout['title'];
$formattedRow['labelId'] = $layout['id'];
Expand Down Expand Up @@ -149,16 +149,16 @@ public static function formatLabel(&$row, &$layout) {
/**
* @param array $formattedRow
*/
public function generateLabel($formattedRow) {
public function generateLabel(array $formattedRow): void {
switch ($formattedRow['labelFormat']) {
case 'A6 Badge Portrait 150x106':
case 'Hanging Badge 3-3/4" x 4-3"/4':
self::labelCreator($formattedRow, 5);
$this->labelCreator($formattedRow, 5);
break;

case 'Avery 5395':
default:
self::labelCreator($formattedRow);
$this->labelCreator($formattedRow);
break;
}
}
Expand All @@ -167,7 +167,7 @@ public function generateLabel($formattedRow) {
* @param array $formattedRow
* @param int $cellspacing
*/
public function labelCreator(&$formattedRow, $cellspacing = 0) {
public function labelCreator($formattedRow, $cellspacing = 0) {
$this->lMarginLogo = 18;
$this->tMarginName = 20;

Expand Down Expand Up @@ -229,7 +229,7 @@ public function labelCreator(&$formattedRow, $cellspacing = 0) {
for ($i = 1; $i <= $rowCount; $i++) {
if (!empty($formattedRow['token'][$i]['token'])) {
$value = '';
if ($formattedRow['token'][$i]['token'] != 'spacer') {
if ($formattedRow['token'][$i]['token'] !== 'spacer') {
$value = $formattedRow['token'][$i]['value'];
}

Expand All @@ -256,7 +256,7 @@ public function labelCreator(&$formattedRow, $cellspacing = 0) {
if (!empty($formattedRow['barcode'])) {
$data = $formattedRow['values'];

if ($formattedRow['barcode']['type'] == 'barcode') {
if ($formattedRow['barcode']['type'] === 'barcode') {
$data['current_value'] = $formattedRow['values']['contact_id'] . '-' . $formattedRow['values']['participant_id'];
}
else {
Expand Down Expand Up @@ -457,6 +457,8 @@ public static function buildBadges(&$params, &$form) {
}
$tokenProcessor->evaluate();
foreach ($tokenProcessor->getRows() as $row) {
$rows[$row->context['participantId']]['contact_id'] = $row->context['contactId'];
$rows[$row->context['participantId']]['participant_id'] = $row->context['participantId'];
foreach ($processorTokens as $processorToken) {
$rows[$row->context['participantId']][$processorToken] = $row->render($processorToken);
}
Expand Down
10 changes: 5 additions & 5 deletions CRM/Badge/Form/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
/**
* Build the form object.
*/
public function buildQuickForm() {
public function buildQuickForm(): void {
if ($this->_action & CRM_Core_Action::DELETE) {
return parent::buildQuickForm();
parent::buildQuickForm();
return;
}

$config = CRM_Core_Config::singleton();
$resources = CRM_Core_Resources::singleton();
$resources->addSetting(
[
Expand Down Expand Up @@ -140,8 +140,8 @@ public function buildQuickForm() {
*/
public function setDefaultValues() {
if (isset($this->_id)) {
$defaults = array_merge($this->_values,
CRM_Badge_BAO_Layout::getDecodedData(CRM_Utils_Array::value('data', $this->_values, '[]')));
$data = empty($this->_values['data']) ? '{}' : $this->_values['data'];
$defaults = array_merge($this->_values, json_decode($data, TRUE));
}
else {
for ($i = 1; $i <= self::FIELD_ROWCOUNT; $i++) {
Expand Down
Loading

0 comments on commit b271739

Please sign in to comment.