Example #1
0
 /**
  * Creates an instance of NfyDbMessage model. The passed message body may be modified, @see formatMessage().
  * This method may be overriden in extending classes.
  * @param string $body message body
  * @return NfyDbMessage
  */
 protected function createMessage($body, $sender_id = null)
 {
     $message = new NfyDbMessage();
     $bodyObj = json_decode($body, true);
     if (isset($bodyObj['identifier'])) {
         $identifier = $bodyObj['identifier'];
     } else {
         $identifier = '';
     }
     if (is_null($sender_id) && $sender_id !== 0) {
         $sender_id = Yii::app()->hasComponent('user') ? Yii::app()->user->getId() : null;
     }
     $message->setAttributes(array('queue_id' => $this->id, 'timeout' => $this->timeout, 'sender_id' => $sender_id, 'status' => NfyMessage::AVAILABLE, 'created_on' => date('Y-m-d H:i:s'), 'body' => $body, 'identifier' => $identifier), false);
     return $this->formatMessage($message);
 }
Example #2
0
 protected function createNotification($body, $notification_id, $object_pk = null, $subject_pk = null)
 {
     $sender_id = Yii::app()->hasComponent('user') ? Yii::app()->user->getId() : null;
     
     $message = new NfyDbMessage;
     $message->setAttributes(array(
         'queue_id' => $this->id,
         'timeout' => $this->timeout,
         'sender_id' => $sender_id,
         'status' => NfyMessage::AVAILABLE,
         'body'=>$body,
         'object_pk'=>$object_pk,
         'notification_id'=>$notification_id,
         'subject_pk'=>$subject_pk
     ), true);
     return $this->formatMessage($message);
 }
Example #3
0
 /**
  * Creates an instance of NfyDbMessage model. The passed message body may be modified, @see formatMessage().
  * This method may be overriden in extending classes.
  * @param string $body message body
  * @return NfyDbMessage
  */
 protected function createMessage($body)
 {
     $message = new NfyDbMessage();
     $message->setAttributes(array('queue_id' => $this->id, 'timeout' => $this->timeout, 'sender_id' => Yii::app()->hasComponent('user') ? Yii::app()->user->getId() : null, 'status' => NfyMessage::AVAILABLE, 'body' => $body), false);
     return $this->formatMessage($message);
 }