Add "invitationAccept" event

This commit is contained in:
Dmitriy Simushev 2014-10-20 12:36:44 +00:00
parent 5ad1044dc0
commit b83cb193f1
2 changed files with 15 additions and 0 deletions

View File

@ -60,6 +60,16 @@ final class Events
*/ */
const INVITATION_CREATE = 'invitationCreate'; const INVITATION_CREATE = 'invitationCreate';
/**
* An invitation is accepted.
*
* This event is triggered after an invitation has been accepted by a
* visitor. An associative array with the following items is passed to the
* event handlers:
* - "invitation": an instance of {@link \Mibew\Thread} class.
*/
const INVITATION_ACCEPT = 'invitationAccept';
/** /**
* An operator cannot be authenticated. * An operator cannot be authenticated.
* *

View File

@ -151,6 +151,8 @@ function invitation_invite($visitor_id, $operator)
/** /**
* Invitation was accepted by visitor * Invitation was accepted by visitor
* *
* Triggers {@link \Mibew\EventDispatcher\Events::INVITATION_ACCEPT} event.
*
* @param int $visitor_id ID of the visitor who accept invitation * @param int $visitor_id ID of the visitor who accept invitation
* @return Thread|boolean Thread object or boolean false on failure * @return Thread|boolean Thread object or boolean false on failure
*/ */
@ -195,6 +197,9 @@ function invitation_accept($visitor_id)
array(':visitor_id' => $visitor_id) array(':visitor_id' => $visitor_id)
); );
$args = array('invitation' => $thread);
EventDispatcher::getInstance()->triggerEvent(Events::INVITATION_ACCEPT, $args);
return $thread; return $thread;
} }