public function onListingSharing(Listing $newListing, User $sender, IResultObject $resultObject) { try { $message = $this->listingNotification->getNotificationMessage($newListing, $sender); $message->markAsSystemMessage(); $this->messagesFacade->sendMessage($message, [$newListing->getUser()->getId()]); } catch (DBALException $e) { $resultObject->addError('Nepodařilo se odeslat zprávu o dopručení sdílené výčetky.', 'error'); } }
public function sendNotifications(Form $form, $values) { $messages = []; foreach ($this->newListings as $listing) { $message = $this->sharedListingNotification->getNotificationMessage($listing, $this->user->getIdentity()->username, $this->users[$listing->getOwnerID()]); $messages[$listing->getOwnerID()] = $message; } try { $this->messagesFacade->sendMessages($messages); } catch (\DibiException $e) { $this->presenter->flashMessage('Nepodařilo se odeslat upozornění příjemcům.', 'warning'); $this->redirect('this'); } $this->redirect('this'); }