Add event on operator create

This commit is contained in:
Dmitriy Simushev 2014-10-17 11:09:10 +00:00
parent 2dca8f236e
commit a34cb53e91
2 changed files with 18 additions and 2 deletions

View File

@ -56,6 +56,16 @@ final class Events
*/
const OPERATOR_LOGOUT = 'operatorLogout';
/**
* An operator is created.
*
* This event is triggered after an operator has been created. An
* associative array with the following items is passed to the event
* handlers:
* - "operator": operator's array.
*/
const OPERATOR_CREATE = 'operatorCreate';
/**
* An operator is deleted.
*

View File

@ -357,6 +357,8 @@ function update_operator_avatar($operator_id, $avatar)
/**
* Create new operator
*
* Triggers {@link \Mibew\EventDispatcher\Events::OPERATOR_CREATE} event.
*
* @param string $login Operator's login
* @param string $email Operator's
* @param string $password Operator's password
@ -398,12 +400,16 @@ function create_operator(
);
$id = $db->insertedId();
return $db->query(
$new_operator = $db->query(
"SELECT * FROM {operator} WHERE operatorid = ?",
array($id),
array('return_rows' => Database::RETURN_ONE_ROW)
);
$event = array('operator' => $new_operator);
EventDispatcher::getInstance()->triggerEvent(Events::OPERATOR_CREATE, $event);
return $new_operator;
}
/**