Add "groupCreate" event

This commit is contained in:
Dmitriy Simushev 2014-10-20 11:17:56 +00:00
parent 9b05509ec4
commit 1aec37b6f6
2 changed files with 16 additions and 0 deletions

View File

@ -32,6 +32,15 @@ final class Events
*/ */
const CRON_RUN = 'cronRun'; const CRON_RUN = 'cronRun';
/**
* A group is created.
*
* This event is triggered after a group has been created. An associative
* array with the following items is passed to the event handlers:
* - "group": group's array.
*/
const GROUP_CREATE = 'groupCreate';
/** /**
* An operator cannot be authenticated. * An operator cannot be authenticated.
* *

View File

@ -18,6 +18,8 @@
*/ */
// Import namespaces and classes of the core // Import namespaces and classes of the core
use Mibew\EventDispatcher\EventDispatcher;
use Mibew\EventDispatcher\Events;
use Mibew\Database; use Mibew\Database;
use Mibew\Settings; use Mibew\Settings;
@ -291,6 +293,8 @@ function check_group_params($group, $extra_params = null)
/** /**
* Creates group * Creates group
* *
* Triggers {@link \Mibew\EventDispatcher\Events::GROUP_CREATE} event.
*
* @param array $group Operators' group. The $group array must contains the * @param array $group Operators' group. The $group array must contains the
* following keys: * following keys:
* - name, * - name,
@ -339,6 +343,9 @@ function create_group($group)
array('return_rows' => Database::RETURN_ONE_ROW) array('return_rows' => Database::RETURN_ONE_ROW)
); );
$args = array('group' => $new_group);
EventDispatcher::getInstance()->triggerEvent(Events::GROUP_CREATE, $args);
return $new_group; return $new_group;
} }