Add "threadClose" event

This commit is contained in:
Dmitriy Simushev 2014-10-20 11:07:50 +00:00
parent 53450ea9d6
commit 9b05509ec4
2 changed files with 14 additions and 0 deletions

View File

@ -186,6 +186,15 @@ final class Events
*/
const THREAD_DELETE = 'threadDelete';
/**
* A thread is closed.
*
* This event is triggered after a thread has been closed. An associative
* array with the following items is passed to the event handlers:
* - "thread": an instance of {@link \Mibew\Thread}.
*/
const THREAD_CLOSE = 'threadClose';
/**
* Threads list is ready to be sent to client.
*

View File

@ -844,6 +844,8 @@ class Thread
/**
* Close thread and send closing messages to the conversation members
*
* Triggers {@link \Mibew\EventDispatcher\Events::THREAD_CLOSE} event.
*
* @param boolean $is_user Boolean TRUE if user initiate thread closing or
* boolean FALSE otherwise
*/
@ -906,6 +908,9 @@ class Thread
$this->closed = time();
$this->messageCount = $message_count;
$this->save();
$args = array('thread' => $this);
EventDispatcher::getInstance()->triggerEvent(Events::THREAD_CLOSE, $args);
}
}