Example #1
0
 /**
  * Fires an event, implicitly calls behaviors and listeners in the events manager are notified
  * This method stops if one of the callbacks/listeners returns boolean false
  *
  * @param string $eventName
  * @return boolean
  * @throws Exception
  */
 public function fireEventCancel($eventName)
 {
     if (is_string($eventName) === false) {
         throw new Exception('Invalid parameter type.');
     }
     //Check if there is a method with the same name of the event
     if (method_exists($this, $eventName) === true) {
         if ($this->{$eventName}() === false) {
             return false;
         }
     }
     //Send a notification to the events manager
     if ($this->_modelsManager->notifyEvent($eventName, $this) === false) {
         return false;
     }
     return true;
 }