Esempio n. 1
0
 /**
  * addEventListener
  *
  * @param string                $event     Le nom de l'évènement
  * @param Callable|array|string $fn        La fonction a lancé quand l'évènement se déclanche
  * @param array                 $nameSpace Le namespace de la classe ou fonction à lancer
  */
 public static function on($event, $fn, array $nameSpace = [])
 {
     if (!is_callable($fn)) {
         static::$nameSpace = $nameSpace;
         static::addEvent($event, $fn, "events");
         Session::add("bow.event.function", static::$events);
     } else {
         static::addEvent($event, $fn, "eventCallback");
     }
 }
Esempio n. 2
0
 /**
  * Constructeur
  */
 private function __construct()
 {
     static::$params = new \stdClass();
     static::$input = new Input();
     Session::add('bow.old', static::$input->all());
 }
Esempio n. 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;
 }
Esempio n. 4
0
 /**
  * Createur de token csrf
  *
  * @param int $time=null
  *
  * @return bool
  */
 public static function createCsrfToken($time = null)
 {
     if (Session::has('bow.csrf')) {
         return false;
     }
     if (is_int($time)) {
         static::$tokenCsrfExpirateTime = $time;
     }
     $token = static::generateCsrfToken();
     Session::add('bow.csrf', (object) ['token' => $token, 'expirate' => time() + static::$tokenCsrfExpirateTime, 'field' => '<input type="hidden" name="_token" value="' . $token . '"/>']);
     Session::add('_token', $token);
     return true;
 }