Example #1
0
 /**
  * emit dispatchEvent
  *
  * @param string $event Le nom de l'évènement
  * @throws EventException
  */
 public static function emit($event)
 {
     $args = array_slice(func_get_args(), 1);
     static::$events = Session::get("bow.event.function");
     $isEmpty = true;
     if (static::$events instanceof Collection) {
         static::$events->collectionify($event)->each(function ($fn) use($args) {
             return Util::launchCallback($fn, $args, static::$nameSpace);
         });
         $isEmpty = false;
     }
     if (static::$eventCallback instanceof Collection) {
         static::$eventCallback->collectionify($event)->each(function ($fn) use($args) {
             return Util::launchCallback($fn, $args);
         });
         $isEmpty = false;
     }
     if ($isEmpty) {
         throw new EventException("Aucun évènement n'est pas enregistré.", E_USER_ERROR);
     }
 }