From 1aec37b6f6b75bf7042d0e2b24d6287c1e164f08 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Mon, 20 Oct 2014 11:17:56 +0000 Subject: [PATCH] Add "groupCreate" event --- src/mibew/libs/classes/Mibew/EventDispatcher/Events.php | 9 +++++++++ src/mibew/libs/groups.php | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php index 7f87c929..ae6843b4 100644 --- a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php +++ b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php @@ -32,6 +32,15 @@ final class Events */ 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. * diff --git a/src/mibew/libs/groups.php b/src/mibew/libs/groups.php index 07872228..0629d2d0 100644 --- a/src/mibew/libs/groups.php +++ b/src/mibew/libs/groups.php @@ -18,6 +18,8 @@ */ // Import namespaces and classes of the core +use Mibew\EventDispatcher\EventDispatcher; +use Mibew\EventDispatcher\Events; use Mibew\Database; use Mibew\Settings; @@ -291,6 +293,8 @@ function check_group_params($group, $extra_params = null) /** * Creates group * + * Triggers {@link \Mibew\EventDispatcher\Events::GROUP_CREATE} event. + * * @param array $group Operators' group. The $group array must contains the * following keys: * - name, @@ -339,6 +343,9 @@ function create_group($group) array('return_rows' => Database::RETURN_ONE_ROW) ); + $args = array('group' => $new_group); + EventDispatcher::getInstance()->triggerEvent(Events::GROUP_CREATE, $args); + return $new_group; }