mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-12 10:31:09 +03:00
Add "banCreate" event
This commit is contained in:
parent
ada83c629a
commit
6263f3a2f4
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
namespace Mibew;
|
namespace Mibew;
|
||||||
|
|
||||||
|
use Mibew\EventDispatcher\EventDispatcher;
|
||||||
|
use Mibew\EventDispatcher\Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that represents Ban entity.
|
* A class that represents Ban entity.
|
||||||
*/
|
*/
|
||||||
@ -193,6 +196,8 @@ class Ban
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the ban to the database.
|
* Save the ban to the database.
|
||||||
|
*
|
||||||
|
* Triggers {@link \Mibew\EventDispatcher\Events::BAN_CREATE} event.
|
||||||
*/
|
*/
|
||||||
public function save()
|
public function save()
|
||||||
{
|
{
|
||||||
@ -211,6 +216,9 @@ class Ban
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->id = $db->insertedId();
|
$this->id = $db->insertedId();
|
||||||
|
|
||||||
|
$args = array('ban' => $this);
|
||||||
|
EventDispatcher::getInstance()->triggerEvent(Events::BAN_CREATE, $args);
|
||||||
} else {
|
} else {
|
||||||
// Update existing ban
|
// Update existing ban
|
||||||
$db->query(
|
$db->query(
|
||||||
|
@ -24,6 +24,15 @@ namespace Mibew\EventDispatcher;
|
|||||||
*/
|
*/
|
||||||
final class Events
|
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.
|
* Cron is run.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user