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);
     }
 }
Example #2
0
 /**
  * Accès au donnée de la précédente requete
  *
  * @param mixed $key
  * @return mixed
  */
 public static function old($key)
 {
     $old = Session::get('bow.old', null);
     return isset($old[$key]) ? $old[$key] : null;
 }
Example #3
0
 /**
  * session
  *
  * @param string $key
  * @param mixed $value
  * @return mixed
  */
 function session($key = null, $value = null)
 {
     if ($key === null && $value === null) {
         return Session::toArray();
     }
     if (Session::has($key)) {
         return Session::get($key);
     }
     if ($key !== null && $value !== null) {
         return Session::add($key, $value);
     }
     return null;
 }
Example #4
0
 /**
  * Détruie le token
  */
 public static function clearCsrfToken()
 {
     Session::remove('bow.csrf');
     Session::remove('_token');
 }