protected function sendMail($topic, $data)
{
$topicNotifies = Notification::getNotifications('topic', $topic->id);
$catNotifies = Notification::getNotifications('category', $topic->category_id);
$notifications = array_merge($topicNotifies->email, $catNotifies->email);
if (!count($notifications)) {
return;
}
$view = $this->getView('Mail');
$view['topic'] = $topic;
$view['siteName'] = HtmlHeader::getSiteName();
$view['link'] = $this->getSuccessRedirect($data);
$body = $view->setLayout('new-post')->render();
$message = SwiftMailer::newMessage('A new reply for topic: ' . $topic->title)->setBody($body);
foreach ($notifications as $notification) {
$message->addTo($notification);
}
SwiftMailer::send($message);
}