Add "banDelete" event

This commit is contained in:
Dmitriy Simushev 2014-10-21 11:51:19 +00:00
parent 6263f3a2f4
commit 7eea7c09d4
2 changed files with 15 additions and 2 deletions

View File

@ -180,6 +180,8 @@ class Ban
/**
* Remove ban from the database.
*
* Triggers {@link \Mibew\EventDispatcher\Events::BAN_DELETE} event.
*/
public function delete()
{
@ -187,11 +189,13 @@ class Ban
throw new \RuntimeException('You cannot delete a ban without id');
}
$db = Database::getInstance();
$db->query(
Database::getInstance()->query(
"DELETE FROM {ban} WHERE banid = :id LIMIT 1",
array(':id' => $this->id)
);
$args = array('id' => $this->id);
EventDispatcher::getInstance()->triggerEvent(Events::BAN_DELETE, $args);
}
/**

View File

@ -33,6 +33,15 @@ final class Events
*/
const BAN_CREATE = 'banCreate';
/**
* A ban is deleted.
*
* This event is triggered after a ban has been deleted. An associative
* array with the following items is passed to the event handlers:
* - "id": int, deleted ban ID.
*/
const BAN_DELETE = 'banDelete';
/**
* Cron is run.
*