mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-07 16:24:43 +03:00
Add "banUpdate" event
This commit is contained in:
parent
7e371a20d9
commit
7f6a9c6513
@ -224,6 +224,9 @@ class Ban
|
|||||||
$args = array('ban' => $this);
|
$args = array('ban' => $this);
|
||||||
EventDispatcher::getInstance()->triggerEvent(Events::BAN_CREATE, $args);
|
EventDispatcher::getInstance()->triggerEvent(Events::BAN_CREATE, $args);
|
||||||
} else {
|
} else {
|
||||||
|
// Get the original state of the ban for "update" event.
|
||||||
|
$original_ban = Ban::load($this->id);
|
||||||
|
|
||||||
// Update existing ban
|
// Update existing ban
|
||||||
$db->query(
|
$db->query(
|
||||||
("UPDATE {ban} SET dtmtill = :till, address = :address, "
|
("UPDATE {ban} SET dtmtill = :till, address = :address, "
|
||||||
@ -235,6 +238,12 @@ class Ban
|
|||||||
':comment' => $this->comment,
|
':comment' => $this->comment,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'ban' => $this,
|
||||||
|
'original_ban' => $original_ban,
|
||||||
|
);
|
||||||
|
EventDispatcher::getInstance()->triggerEvent(Events::BAN_UPDATE, $args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,6 +33,18 @@ final class Events
|
|||||||
*/
|
*/
|
||||||
const BAN_CREATE = 'banCreate';
|
const BAN_CREATE = 'banCreate';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A ban is updated.
|
||||||
|
*
|
||||||
|
* This event is triggered after a ban is saved. An associative array with
|
||||||
|
* the following items is passed to the event handlers:
|
||||||
|
* - "ban": an instance of {@link \Mibew\Ban}, the state of the ban after
|
||||||
|
* the update.
|
||||||
|
* - "original_ban": an instance of {@link \Mibew\Ban}, the state of the
|
||||||
|
* ban before the update.
|
||||||
|
*/
|
||||||
|
const BAN_UPDATE = 'banUpdate';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ban is deleted.
|
* A ban is deleted.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user