set() public static method

public static set ( )
Beispiel #1
0
 public static function getCsrfToken()
 {
     if (Session::has('csrftoken')) {
         return Session::get('csrftoken');
     }
     $token = self::generateCsrfToken();
     Session::set('csrftoken', $token);
     return $token;
 }
Beispiel #2
0
 /**
  * @return Event[]
  */
 public static function loadNew()
 {
     $lastEventId = Session::get('last_event_id');
     if (!$lastEventId) {
         //do not load events that we triggered before this session was started
         /** @var Event $lastEvent */
         $lastEvent = Event::queryBuilder()->limit(1)->order('id desc')->fetch();
         Session::set('last_event_id', $lastEvent ? $lastEvent->id : 0);
     }
     $events = Event::where(['id' => Restrictions::greaterThan($lastEventId)])->order('id asc')->fetchAll();
     if ($events) {
         Session::set('last_event_id', Arrays::last($events)->id);
     }
     return $events;
 }
Beispiel #3
0
 private function saveMessagesWithEmptyCheck($messages)
 {
     if ($messages) {
         Session::set('messages', $messages);
     } else {
         Session::remove('messages');
     }
 }
Beispiel #4
0
 /**
  * @test
  */
 public function shouldGetAllValuesFromSession()
 {
     //given
     Session::set('key', 'value');
     //when
     $all = Session::all();
     //then
     Assert::thatArray($all)->hasSize(1)->containsKeyAndValue(array('key' => 'value'));
 }
Beispiel #5
0
 private static function removeExcessiveRequests()
 {
     $all = Session::get('stats_queries');
     if (sizeof($all) > self::NUMBER_OF_REQUESTS_TO_KEEP) {
         while (sizeof($all) > self::NUMBER_OF_REQUESTS_TO_KEEP) {
             array_shift($all);
         }
         Session::set('stats_queries', $all);
     }
 }