From 9b05509ec48304fb0c3889d33484a1caa1a2169d Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Mon, 20 Oct 2014 11:07:50 +0000 Subject: [PATCH] Add "threadClose" 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 1c375ef3..7f87c929 100644 --- a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php +++ b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php @@ -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. * diff --git a/src/mibew/libs/classes/Mibew/Thread.php b/src/mibew/libs/classes/Mibew/Thread.php index c6a22609..083b8023 100644 --- a/src/mibew/libs/classes/Mibew/Thread.php +++ b/src/mibew/libs/classes/Mibew/Thread.php @@ -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); } }