get() public static méthode

public static get ( )
Exemple #1
0
 public static function getCsrfToken()
 {
     if (Session::has('csrftoken')) {
         return Session::get('csrftoken');
     }
     $token = self::generateCsrfToken();
     Session::set('csrftoken', $token);
     return $token;
 }
Exemple #2
0
function showSuccess(array $notices = array())
{
    if (Session::has('messages') || $notices) {
        $sessionMessages = Arrays::filterNotBlank(Arrays::toArray(Session::get('messages')));
        $notices = array_merge($sessionMessages, $notices);
        $noticeView = new View('success_alert');
        $noticeView->notices = $notices;
        return $noticeView->render();
    }
    return null;
}
Exemple #3
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;
 }
Exemple #4
0
 private function _removeMessages()
 {
     if (!$this->_keepMessage && Session::has('messages')) {
         $messages = Arrays::filter(Session::get('messages'), function (Notice $notice) {
             return !$notice->requestUrlMatches();
         });
         $this->saveMessagesWithEmptyCheck($messages);
     }
 }
Exemple #5
0
 private function _getConfigFromSession()
 {
     return Session::get('config') ?: array();
 }
 /**
  * @test
  */
 public function shouldSaveStatsIfDebugIsOn()
 {
     //given
     Config::overrideProperty('debug')->with(true);
     Session::remove('stats_queries');
     Route::get('/sample/save', 'sample#save');
     //when
     $this->get('/sample/save');
     //then
     $this->assertNotEmpty(Session::get('stats_queries'));
 }
Exemple #7
0
 /**
  * @test
  */
 public function shouldRemoveNoticeIfUrlIsWithQueryPath()
 {
     //given
     Route::allowAll('/simple_test', 'simple_test');
     $this->get('/simple_test/notice_with_query?data=some-data');
     //when
     $this->get('/simple_test/other_action');
     //then
     $this->assertEmpty(Session::get('messages'));
 }
Exemple #8
0
 /**
  * @test
  */
 public function shouldPushNestedSessionValueWhenArrayIsNotEmpty()
 {
     // given
     Session::push('key1', 'key2', 'value1');
     Session::push('key1', 'key2', 'value2');
     //when
     Session::push('key1', 'key2', 'value3');
     //then
     Assert::thatSession()->hasSize(1);
     $value = Session::get('key1', 'key2');
     Assert::thatArray($value)->containsExactly('value1', 'value2', 'value3');
 }
Exemple #9
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);
     }
 }