Throw exception when a plugin tries to change the cancel event of a non-Cancellable event

This commit is contained in:
Shoghi Cervantes
2014-06-18 19:36:32 +02:00
parent 825656feed
commit a0ac660d57
2 changed files with 34 additions and 12 deletions

View File

@ -46,8 +46,13 @@ abstract class Event{
/**
* @return bool
*
* @throws \BadMethodCallException
*/
public function isCancelled(){
if(!($this instanceof Cancellable)){
throw new \BadMethodCallException("Event is not Cancellable");
}
return $this->isCancelled === true;
}
@ -55,8 +60,13 @@ abstract class Event{
* @param bool $value
*
* @return bool
*
* @throws \BadMethodCallException
*/
public function setCancelled($value = true){
if(!($this instanceof Cancellable)){
throw new \BadMethodCallException("Event is not Cancellable");
}
$this->isCancelled = (bool) $value;
}