diff --git a/src/mibew/libs/classes/Mibew/Ban.php b/src/mibew/libs/classes/Mibew/Ban.php index 3d7dfe52..4ea78304 100644 --- a/src/mibew/libs/classes/Mibew/Ban.php +++ b/src/mibew/libs/classes/Mibew/Ban.php @@ -19,6 +19,9 @@ namespace Mibew; +use Mibew\EventDispatcher\EventDispatcher; +use Mibew\EventDispatcher\Events; + /** * A class that represents Ban entity. */ @@ -193,6 +196,8 @@ class Ban /** * Save the ban to the database. + * + * Triggers {@link \Mibew\EventDispatcher\Events::BAN_CREATE} event. */ public function save() { @@ -211,6 +216,9 @@ class Ban ) ); $this->id = $db->insertedId(); + + $args = array('ban' => $this); + EventDispatcher::getInstance()->triggerEvent(Events::BAN_CREATE, $args); } else { // Update existing ban $db->query( diff --git a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php index 59873ffa..03986261 100644 --- a/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php +++ b/src/mibew/libs/classes/Mibew/EventDispatcher/Events.php @@ -24,6 +24,15 @@ namespace Mibew\EventDispatcher; */ final class Events { + /** + * A ban is created. + * + * This event is triggered after a ban has been created. An associative + * array with the following items is passed to the event handlers: + * - "ban": an instance of {@link \Mibew\Ban} class. + */ + const BAN_CREATE = 'banCreate'; + /** * Cron is run. *