codefog / contao-events_subscriptions

Contao extension that allows members of your website to subscribe to the events
MIT License
10 stars 5 forks source link

Warning: Undefined array key "subscribersParticipants" #105

Open Defcon0 opened 8 months ago

Defcon0 commented 8 months ago

Hello,

in debug mode I get

Warning: Undefined array key "subscribersParticipants"

in

vendor/codefog/contao-events_subscriptions/src/Codefog/EventsSubscriptions/FrontendModule/SubscriptionTrait.php:145

What about checking if it's set and if not, setting it?

$subscribers[($isOnWaitingList ? 'waitingList' : 'subscribers')][] = $subscription->getFrontendLabel();
$subscribers[($isOnWaitingList ? 'waitingListParticipants' : 'subscribersParticipants')] += $model->numberOfParticipants;

to

$subscribers[($isOnWaitingList ? 'waitingList' : 'subscribers')][] = $subscription->getFrontendLabel();

if (!isset($subscribers[($isOnWaitingList ? 'waitingListParticipants' : 'subscribersParticipants')])) {
  $subscribers[($isOnWaitingList ? 'waitingListParticipants' : 'subscribersParticipants')] = 0;
}

$subscribers[($isOnWaitingList ? 'waitingListParticipants' : 'subscribersParticipants')] += $model->numberOfParticipants;