/** * 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); } }
/** * 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; }
/** * 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; }
/** * Retourne un token csrf générer * * @return mixed */ public static function getCsrfToken() { return Session::get('bow.csrf'); }