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

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

addNotification
public static addNotification ( string $type = 'topic', integer $targetId, integer $userId ) : mixed | Windwalker\Data\Data
$type string
$targetId integer
$userId integer
Результат mixed | Windwalker\Data\Data
    public static function addNotification($type = 'topic', $targetId, $userId)
    {
        $mapper = new NotificationMapper();
        $notify = $mapper->findOne(['user_id' => $userId, 'target_id' => $targetId, 'type' => $type]);
        if ($notify->isNull()) {
            $notify = $mapper->createOne(array('target_id' => $targetId, 'user_id' => $userId, 'type' => $type));
        }
        return $notify;
    }

Usage Example

Пример #1
0
 /**
  * postSave
  *
  * @param Data $data
  *
  * @throws ValidFailException
  */
 protected function postSave(Data $data)
 {
     $input = array('item' => array('topic_id' => $data->id, 'primary' => 1, 'body' => $data->body));
     if (!$this->hmvc($controller = new \Forum\Controller\Post\SaveController(), $input)) {
         list($url, $msg, $type) = $controller->getRedirect(true);
         throw new ValidFailException($msg);
     }
     $post = $controller->getPost();
     $data->last_reply_post = $post->id;
     // Add Notification
     Notification::addNotification('topic', $data->id, $data->user_id);
 }
All Usage Examples Of Forum\Notification\Notification::addNotification