mirror of
https://github.com/Mibew/mibew.git
synced 2024-11-15 16:44:11 +03:00
Move "threadUpdate" event to Events class
This commit is contained in:
parent
d05fe335b8
commit
60bd21bf42
@ -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.
|
||||
*
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user