private function sendToSubscriptions($subscriptions, $queueMessage)
{
$success = true;
foreach ($subscriptions as $subscription) {
$subscriptionMessage = clone $queueMessage;
$subscriptionMessage->subscription_id = $subscription->id;
$subscriptionMessage->message_id = $queueMessage->id;
if ($this->beforeSendSubscription($subscriptionMessage, $subscription->subscriber_id) !== true) {
continue;
}
if (!$subscriptionMessage->save()) {
Yii::error(Yii::t('app', "Failed to save message '{msg}' in queue {queue_label} for the subscription {subscription_id}.", ['msg' => $queueMessage->body, 'queue_label' => $this->label, 'subscription_id' => $subscription->id]) . ' ' . print_r($subscriptionMessage->getErrors(), true), 'nfy');
$success = false;
}
$this->afterSendSubscription($subscriptionMessage, $subscription->subscriber_id);
}
return $success;
}