crazedsanity/messaging

Method to create + add message to queue immediately

Opened this issue · 0 comments

There should be a way to call something like MessageQueue::addMessage($title, $body, $type=null) which would create a Message object and immediately add it to the MessageQueue. Basically, it would do something similar to this function:

function addAlert($title, $body, $type=null) {
	$x = new Message(false);
	$x->title = $title;
	$x->body = $body;
	
	if(!empty($type) && in_array($type, Message::$validTypes)) {
		$x->type = $type;
	}
	else {
		$x->type = Message::DEFAULT_TYPE;
	}
	
	$q = new MessageQueue(true);
	$q->add($x);
}