Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

"HttpSession" has been renamed to "SessionStorage" in controllers

  • Loading branch information...
commit 62e37808204b687776deac83dc2455f7c0d22672 1 parent c11f74c
Ismael Ambrosi authored
18  src/ServerGrove/SGLiveChatBundle/Controller/AdminController.php
@@ -36,7 +36,7 @@ private function createLoginForm($operator = null)
36 36
 
37 37
     private function isLogged()
38 38
     {
39  
-        return $this->getHttpSession()->get('_operator');
  39
+        return $this->getSessionStorage()->get('_operator');
40 40
     }
41 41
 
42 42
     private function checkLogin()
@@ -73,12 +73,12 @@ public function checkLoginAction()
73 73
                 throw new UsernameNotFoundException('Invalid password');
74 74
             }
75 75
 
76  
-            $this->getHttpSession()->set('_operator', $operator->getId());
  76
+            $this->getSessionStorage()->set('_operator', $operator->getId());
77 77
             $operator->setIsOnline(true);
78 78
             $this->getDocumentManager()->persist($operator);
79 79
             $this->getDocumentManager()->flush();
80 80
         } catch (UsernameNotFoundException $e) {
81  
-            $this->getHttpSession()->setFlash('_error', $e->getMessage());
  81
+            $this->getSessionStorage()->setFlash('_error', $e->getMessage());
82 82
             return $this->redirect($this->generateUrl("_security_login", array(
83 83
                 'e' => __LINE__)));
84 84
         }
@@ -97,7 +97,7 @@ public function indexAction()
97 97
 
98 98
     public function loginAction()
99 99
     {
100  
-        $errorMsg = $this->getHttpSession()->getFlash('_error');
  100
+        $errorMsg = $this->getSessionStorage()->getFlash('_error');
101 101
         $form = $this->createLoginForm();
102 102
 
103 103
         return $this->renderTemplate('SGLiveChatBundle:Admin:login.html.twig', array(
@@ -113,7 +113,7 @@ public function logoutAction()
113 113
             $this->getDocumentManager()->persist($operator);
114 114
             $this->getDocumentManager()->flush();
115 115
 
116  
-            $this->getHttpSession()->remove('_operator');
  116
+            $this->getSessionStorage()->remove('_operator');
117 117
         }
118 118
 
119 119
         if (!is_null($response = $this->checkLogin())) {
@@ -243,7 +243,7 @@ public function operatorsAction()
243 243
         }
244 244
 
245 245
         $operators = $this->getDocumentManager()->getRepository('SGLiveChatBundle:Operator')->findAll();
246  
-        $msg = $this->getHttpSession()->getFlash('msg', '');
  246
+        $msg = $this->getSessionStorage()->getFlash('msg', '');
247 247
         return $this->renderTemplate('SGLiveChatBundle:Admin:operators.html.twig', array(
248 248
             'operators' => $operators,
249 249
             'msg' => $msg));
@@ -274,7 +274,7 @@ public function operatorDepartmentAction($id = null)
274 274
                     $department->setIsActive(isset($params['isActive']) && $params['isActive']);
275 275
                     $this->getDocumentManager()->persist($department);
276 276
                     $this->getDocumentManager()->flush();
277  
-                    $this->getHttpSession()->setFlash('msg', 'The department has been successfully updated');
  277
+                    $this->getSessionStorage()->setFlash('msg', 'The department has been successfully updated');
278 278
 
279 279
                     return $this->redirect($this->generateUrl('sglc_admin_operator_departments'));
280 280
                 }
@@ -294,7 +294,7 @@ public function operatorDepartmentsAction()
294 294
         $this->checkLogin();
295 295
 
296 296
         $departments = $this->getDocumentManager()->getRepository('SGLiveChatBundle:Operator\Department')->findAll();
297  
-        $msg = $this->getHttpSession()->getFlash('msg', '');
  297
+        $msg = $this->getSessionStorage()->getFlash('msg', '');
298 298
 
299 299
         return $this->renderTemplate('SGLiveChatBundle:Admin:operator-departments.html.twig', array(
300 300
             'departments' => $departments,
@@ -331,7 +331,7 @@ public function operatorAction($id = null)
331 331
                     $operator->setIsActive(isset($params['isActive']) && $params['isActive']);
332 332
                     $this->getDocumentManager()->persist($operator);
333 333
                     $this->getDocumentManager()->flush();
334  
-                    $this->getHttpSession()->setFlash('msg', 'The operator has been successfully updated');
  334
+                    $this->getSessionStorage()->setFlash('msg', 'The operator has been successfully updated');
335 335
 
336 336
                     return $this->redirect($this->generateUrl('sglc_admin_operators'));
337 337
                 }
8  src/ServerGrove/SGLiveChatBundle/Controller/BaseController.php
@@ -6,7 +6,7 @@
6 6
 use Symfony\Component\HttpFoundation\Request;
7 7
 use Symfony\Component\HttpFoundation\Response;
8 8
 use Symfony\Component\HttpFoundation\Cookie;
9  
-use Symfony\Component\HttpFoundation\Session as HttpSession;
  9
+use Symfony\Component\HttpFoundation\Session as SessionStorage;
10 10
 use Doctrine\ODM\MongoDB\DocumentManager;
11 11
 
12 12
 /**
@@ -44,7 +44,7 @@ public function getResponse()
44 44
     /**
45 45
      * @return Symfony\Component\HttpFoundation\Session
46 46
      */
47  
-    public function getHttpSession()
  47
+    public function getSessionStorage()
48 48
     {
49 49
         if (is_null($this->session)) {
50 50
             $this->session = $this->getRequest()->getSession();
@@ -85,10 +85,10 @@ public function redirect($url, $status = 302)
85 85
      */
86 86
     protected function getOperator()
87 87
     {
88  
-        if (!$this->getHttpSession()->has('_operator')) {
  88
+        if (!$this->getSessionStorage()->has('_operator')) {
89 89
             return null;
90 90
         }
91  
-        return $this->getDocumentManager()->find('SGLiveChatBundle:Operator', $this->getHttpSession()->get('_operator'));
  91
+        return $this->getDocumentManager()->find('SGLiveChatBundle:Operator', $this->getSessionStorage()->get('_operator'));
92 92
     }
93 93
 
94 94
     /**
52  src/ServerGrove/SGLiveChatBundle/Controller/ChatController.php
@@ -35,7 +35,7 @@ private function getChatSession($id)
35 35
      */
36 36
     public function getChatSessionForCurrentUser()
37 37
     {
38  
-        return $this->getChatSession($this->getHttpSession()->has('_operator') ? $this->getRequest()->get('id') : $this->getHttpSession()->get('chatsession'));
  38
+        return $this->getChatSession($this->getSessionStorage()->has('_operator') ? $this->getRequest()->get('id') : $this->getSessionStorage()->get('chatsession'));
39 39
     }
40 40
 
41 41
     /**
@@ -48,8 +48,8 @@ private function getCannedMessages()
48 48
 
49 49
     private function cacheUserForSession(User $user, Session $chatSession)
50 50
     {
51  
-        $this->getHttpSession()->set('userId-' . $chatSession->getId(), $user->getId());
52  
-        $this->getHttpSession()->set('userKind-' . $chatSession->getId(), $user->getKind());
  51
+        $this->getSessionStorage()->set('userId-' . $chatSession->getId(), $user->getId());
  52
+        $this->getSessionStorage()->set('userKind-' . $chatSession->getId(), $user->getKind());
53 53
     }
54 54
 
55 55
     /**
@@ -58,12 +58,12 @@ private function cacheUserForSession(User $user, Session $chatSession)
58 58
      */
59 59
     private function getUserForSession(Session $chatSession)
60 60
     {
61  
-        if (!$this->getHttpSession()->has('userId-' . $chatSession->getId()) || !$this->getHttpSession()->has('userKind-' . $chatSession->getId())) {
  61
+        if (!$this->getSessionStorage()->has('userId-' . $chatSession->getId()) || !$this->getSessionStorage()->has('userKind-' . $chatSession->getId())) {
62 62
             throw new Exception('No user stored');
63 63
         }
64 64
 
65  
-        $userId = $this->getHttpSession()->get('userId-' . $chatSession->getId());
66  
-        $userKind = $this->getHttpSession()->get('userKind-' . $chatSession->getId());
  65
+        $userId = $this->getSessionStorage()->get('userId-' . $chatSession->getId());
  66
+        $userKind = $this->getSessionStorage()->get('userKind-' . $chatSession->getId());
67 67
         return $this->getDocumentManager()->find('SGLiveChatBundle:' . ($userKind == 'Guest' ? 'Visitor' : 'Operator'), $userId);
68 68
     }
69 69
 
@@ -99,7 +99,7 @@ public function indexAction()
99 99
 
100 100
             $this->getDocumentManager()->flush();
101 101
 
102  
-            $this->getHttpSession()->set('chatsession', $chatSession->getId());
  102
+            $this->getSessionStorage()->set('chatsession', $chatSession->getId());
103 103
             $this->cacheUserForSession($visitor, $chatSession);
104 104
 
105 105
             return $this->redirect($this->generateUrl('sglc_chat_load', array(
@@ -108,7 +108,7 @@ public function indexAction()
108 108
 
109 109
         return $this->renderTemplate('SGLiveChatBundle:Chat:index.html.twig', array(
110 110
             'visitor' => $visitor,
111  
-            'errorMsg' => $this->getHttpSession()->getFlash('errorMsg', null)));
  111
+            'errorMsg' => $this->getSessionStorage()->getFlash('errorMsg', null)));
112 112
     }
113 113
 
114 114
     public function inviteAction($sessId)
@@ -116,7 +116,7 @@ public function inviteAction($sessId)
116 116
         $operator = $this->getOperator();
117 117
 
118 118
         if (!$operator) {
119  
-            $this->getHttpSession()->setFlash('errorMsg', 'Unauthorized access.');
  119
+            $this->getSessionStorage()->setFlash('errorMsg', 'Unauthorized access.');
120 120
 
121 121
             return $this->redirect($this->generateUrl('sglc_chat_homepage'));
122 122
         }
@@ -152,13 +152,13 @@ public function inviteAction($sessId)
152 152
     public function acceptInviteAction($id)
153 153
     {
154 154
         if (!($chatSession = $this->getChatSession($id))) {
155  
-            $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
  155
+            $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
156 156
 
157 157
             return $this->redirect($this->generateUrl('sglc_chat_homepage'));
158 158
         }
159 159
 
160 160
         if ($chatSession->getStatusId() != Session::STATUS_INVITE) {
161  
-            $this->getHttpSession()->setFlash('errorMsg', 'Invitation has expired or canceled. You can start a new chat now.');
  161
+            $this->getSessionStorage()->setFlash('errorMsg', 'Invitation has expired or canceled. You can start a new chat now.');
162 162
 
163 163
             return $this->redirect($this->generateUrl('sglc_chat_homepage'));
164 164
         }
@@ -172,7 +172,7 @@ public function acceptInviteAction($id)
172 172
     public function rejectInviteAction($id)
173 173
     {
174 174
         if (!($chatSession = $this->getChatSession($id))) {
175  
-            $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
  175
+            $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
176 176
 
177 177
             return $this->getResponse();
178 178
         }
@@ -187,13 +187,13 @@ public function acceptAction($id)
187 187
         $operator = $this->getOperator();
188 188
 
189 189
         if (!$operator) {
190  
-            $this->getHttpSession()->setFlash('errorMsg', 'Unauthorized access.');
  190
+            $this->getSessionStorage()->setFlash('errorMsg', 'Unauthorized access.');
191 191
 
192 192
             return $this->redirect($this->generateUrl('sglc_chat_homepage'));
193 193
         }
194 194
 
195 195
         if (!($chatSession = $this->getChatSession($id))) {
196  
-            $this->getHttpSession()->setFlash('errorMsg', 'Chat not found');
  196
+            $this->getSessionStorage()->setFlash('errorMsg', 'Chat not found');
197 197
 
198 198
             return $this->redirect($this->generateUrl('sglc_chat_homepage'));
199 199
         }
@@ -228,7 +228,7 @@ public function loadAction()
228 228
     {
229 229
         $operator = $this->getOperator();
230 230
         if (!($chatSession = $this->getChatSessionForCurrentUser())) {
231  
-            $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
  231
+            $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
232 232
             return $this->redirect($this->generateUrl('sglc_chat_homepage'));
233 233
         }
234 234
 
@@ -245,9 +245,9 @@ public function loadAction()
245 245
             }
246 246
         }
247 247
 
248  
-        $this->getHttpSession()->set('chatStatus' . $chatSession->getId(), '');
  248
+        $this->getSessionStorage()->set('chatStatus' . $chatSession->getId(), '');
249 249
 
250  
-        $this->getHttpSession()->set('lastMessage', 0);
  250
+        $this->getSessionStorage()->set('lastMessage', 0);
251 251
 
252 252
         $user = $this->getUserForSession($chatSession);
253 253
         return $this->renderTemplate('SGLiveChatBundle:Chat:load.html.twig', array(
@@ -272,7 +272,7 @@ public function sendAction($id)
272 272
         }
273 273
 
274 274
         if (!$chatSession = $this->getChatSession($id)) {
275  
-            $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
  275
+            $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
276 276
             return $this->redirect($this->generateUrl('sglc_chat_homepage'));
277 277
         }
278 278
 
@@ -306,12 +306,12 @@ public function messagesAction($_format)
306 306
         $this->getDocumentManager()->persist($chatSession);
307 307
         $this->getDocumentManager()->flush();
308 308
 
309  
-        if ($this->getHttpSession()->has('lastMessage')) {
310  
-            $last = $this->getHttpSession()->get('lastMessage');
  309
+        if ($this->getSessionStorage()->has('lastMessage')) {
  310
+            $last = $this->getSessionStorage()->get('lastMessage');
311 311
         } else {
312 312
             $last = 0;
313 313
         }
314  
-        $this->getHttpSession()->set('lastMessage', count($messages));
  314
+        $this->getSessionStorage()->set('lastMessage', count($messages));
315 315
 
316 316
         if ($last) {
317 317
             $messages = array_slice($messages->toArray(), $last);
@@ -346,7 +346,7 @@ public function messagesAction($_format)
346 346
     public function doneAction()
347 347
     {
348 348
         if (!$chatSession = $this->getChatSessionForCurrentUser()) {
349  
-            $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
  349
+            $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
350 350
             return $this->redirect($this->generateUrl('sglc_chat_homepage'));
351 351
         }
352 352
 
@@ -397,15 +397,15 @@ public function statusAction()
397 397
         }
398 398
 
399 399
         if (!$chatSession = $this->getChatSessionForCurrentUser()) {
400  
-            $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
  400
+            $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
401 401
             $this->getResponse()->headers->set('Content-type', 'text/javascript');
402 402
             $this->getResponse()->setContent(sprintf('location.href = %s;', var_export($this->generateUrl('sglc_chat_homepage'), true)));
403 403
 
404 404
             return $this->getResponse();
405 405
         }
406 406
 
407  
-        if ($chatSession->getOperator() && $chatSession->getStatusId() == Session::STATUS_IN_PROGRESS && $this->getHttpSession()->get('chatStatus' . $chatSession->getId()) != 'started') {
408  
-            $this->getHttpSession()->set('chatStatus' . $chatSession->getId(), 'started');
  407
+        if ($chatSession->getOperator() && $chatSession->getStatusId() == Session::STATUS_IN_PROGRESS && $this->getSessionStorage()->get('chatStatus' . $chatSession->getId()) != 'started') {
  408
+            $this->getSessionStorage()->set('chatStatus' . $chatSession->getId(), 'started');
409 409
             $this->getResponse()->headers->set('Content-type', 'text/javascript');
410 410
             $this->getResponse()->setContent('Chat.get().start();');
411 411
 
@@ -413,7 +413,7 @@ public function statusAction()
413 413
         }
414 414
 
415 415
         if ($chatSession->getStatusId() == Session::STATUS_CLOSED || $chatSession->getStatusId() == Session::STATUS_CANCELED) {
416  
-            $this->getHttpSession()->setFlash('errorMsg', 'Chat has been ' . $chatSession->getStatus());
  416
+            $this->getSessionStorage()->setFlash('errorMsg', 'Chat has been ' . $chatSession->getStatus());
417 417
             $this->getResponse()->headers->set('Content-type', 'text/javascript');
418 418
 
419 419
             $this->getResponse()->setContent(sprintf('location.href = %s;', var_export($this->generateUrl('sglc_chat_homepage'), true)));
8  src/ServerGrove/SGLiveChatBundle/Controller/TrackController.php
@@ -61,8 +61,8 @@ public function updateAction()
61 61
             /* @var $chat \ServerGrove\SGLiveChatBundle\Document\Session */
62 62
             $chat = current($chats);
63 63
 
64  
-            if (!$this->getHttpSession()->get('chat_invite', null)) {
65  
-                $this->getHttpSession()->set('chat_invite', $chat->getId());
  64
+            if (!$this->getSessionStorage()->get('chat_invite', null)) {
  65
+                $this->getSessionStorage()->set('chat_invite', $chat->getId());
66 66
             }
67 67
 
68 68
             $this->getResponse()->headers->set('Content-type', 'text/javascript');
@@ -70,8 +70,8 @@ public function updateAction()
70 70
             return $this->renderTemplate('SGLiveChatBundle:Track:create-invite-box.js.twig', array(
71 71
                 'chat' => $chat));
72 72
         } else {
73  
-            if ($this->getHttpSession()->get('chat_invite')) {
74  
-                $this->getHttpSession()->set('chat_invite', null);
  73
+            if ($this->getSessionStorage()->get('chat_invite')) {
  74
+                $this->getSessionStorage()->set('chat_invite', null);
75 75
 
76 76
                 $this->getResponse()->headers->set('Content-type', 'text/javascript');
77 77
 

0 notes on commit 62e3780

Please sign in to comment.
Something went wrong with that request. Please try again.