From 53450ea9d6706da878f059153202eb8e78c4f40d Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Mon, 20 Oct 2014 10:55:22 +0000 Subject: [PATCH] Create "threadDelete" event --- src/mibew/libs/classes/Mibew/EventDispatcher/Events.php | 9 +++++++++ src/mibew/libs/classes/Mibew/Thread.php | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php index 954ee867..1c375ef3 100644 --- a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php +++ b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php @@ -177,6 +177,15 @@ final class Events */ 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. * diff --git a/src/mibew/libs/classes/Mibew/Thread.php b/src/mibew/libs/classes/Mibew/Thread.php index ec32e5ea..c6a22609 100644 --- a/src/mibew/libs/classes/Mibew/Thread.php +++ b/src/mibew/libs/classes/Mibew/Thread.php @@ -532,6 +532,8 @@ class Thread /** * Remove thread from database + * + * Triggers {@link \Mibew\EventDispatcher\Events::THREAD_DELETE} event. */ public function delete() { @@ -540,6 +542,9 @@ class Thread "DELETE FROM {thread} WHERE threadid = :id LIMIT 1", array(':id' => $this->id) ); + + $args = array('id' => $this->id); + EventDispatcher::getInstance()->triggerEvent(Events::THREAD_DELETE, $args); } /**