diff --git a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php index 5745811c..954ee867 100644 --- a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php +++ b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php @@ -164,6 +164,19 @@ final class Events */ const RESOURCE_NOT_FOUND = 'resourceNotFound'; + /** + * Thread is updated. + * + * This event is triggered after a thread is saved and only if some of its + * fields have been changed. An associative array with the following items + * is passed to the event handlers: + * - "thread": Thread object that was chanded. + * - "changed_fields": list of changed fields. Names of the fields + * correspond to class properties (see {@link \Mibew\Thread::propertyMap} + * for details). + */ + const THREAD_UPDATE = 'threadUpdate'; + /** * 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 998bd2a3..ec32e5ea 100644 --- a/src/mibew/libs/classes/Mibew/Thread.php +++ b/src/mibew/libs/classes/Mibew/Thread.php @@ -21,25 +21,12 @@ namespace Mibew; // Import namespaces and classes of the core use Mibew\EventDispatcher\EventDispatcher; +use Mibew\EventDispatcher\Events; use Mibew\RequestProcessor\ThreadProcessor; /** * Represents a chat thread * - * Events triggered by the class - * - threadChanged - * - * Full description of triggered events: - * - * 1. "threadChanged" - triggers just after thread saved and only if some thread - * fields were changed before. - * - * An associative array passed to event handler has following keys: - * - 'thread': Thread object that was chanded. - * - 'changed_fields': list of changed fields. Names of the fields correspond - * to class properties (see Thread::propertyMap for details) NOT to fields - * names in database. - * * @todo Think about STATE_* and KIND_* constant systems and may be simplifies * them. */ @@ -649,6 +636,8 @@ class Thread /** * Save the thread to the database * + * Triggers {@link \Mibew\EventDispatcher\Events::THREAD_UPDATE} event. + * * @param boolean $update_revision Indicates if last modified time and last * revision should be updated. */ @@ -686,7 +675,7 @@ class Thread 'changed_fields' => $this->changedFields, ); $dispatcher = EventDispatcher::getInstance(); - $dispatcher->triggerEvent('threadChanged', $args); + $dispatcher->triggerEvent(Events::THREAD_UPDATE, $args); // Clear updated fields $this->changedFields = array();