Forum\Notification\Notification::getNotifications PHP Метод

getNotifications() публичный статический Метод

getNotifications
public static getNotifications ( string $type, integer $targetId ) : mixed | Windwalker\Data\DataSet
$type string
$targetId integer
Результат mixed | Windwalker\Data\DataSet
    public static function getNotifications($type, $targetId)
    {
        return RelationDataMapper::getInstance('user', WarderTable::USERS)->addTable('notification', Table::NOTIFICATIONS, 'notification.user_id = user.id')->find(['notification.target_id' => $targetId, 'type' => $type]);
    }

Usage Example

Пример #1
0
 /**
  * sendMail
  *
  * @param Record $topic
  * @param Data   $data
  *
  * @return  void
  */
 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);
 }