Create "threadDelete" event

This commit is contained in:
Dmitriy Simushev 2014-10-20 10:55:22 +00:00
parent 60bd21bf42
commit 53450ea9d6
2 changed files with 14 additions and 0 deletions

View File

@ -177,6 +177,15 @@ final class Events
*/ */
const THREAD_UPDATE = 'threadUpdate'; const THREAD_UPDATE = 'threadUpdate';
/**
* A thread is deleted.
*
* This event is triggered after a thread has been deleted. An associative
* array with the following items is passed to the event handlers:
* - "id": int, deleted thread ID.
*/
const THREAD_DELETE = 'threadDelete';
/** /**
* Threads list is ready to be sent to client. * Threads list is ready to be sent to client.
* *

View File

@ -532,6 +532,8 @@ class Thread
/** /**
* Remove thread from database * Remove thread from database
*
* Triggers {@link \Mibew\EventDispatcher\Events::THREAD_DELETE} event.
*/ */
public function delete() public function delete()
{ {
@ -540,6 +542,9 @@ class Thread
"DELETE FROM {thread} WHERE threadid = :id LIMIT 1", "DELETE FROM {thread} WHERE threadid = :id LIMIT 1",
array(':id' => $this->id) array(':id' => $this->id)
); );
$args = array('id' => $this->id);
EventDispatcher::getInstance()->triggerEvent(Events::THREAD_DELETE, $args);
} }
/** /**