Permalink
Browse files

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

  • Loading branch information...
1 parent c11f74c commit 62e37808204b687776deac83dc2455f7c0d22672 @iambrosi iambrosi committed Mar 4, 2011
View
18 src/ServerGrove/SGLiveChatBundle/Controller/AdminController.php
@@ -36,7 +36,7 @@ private function createLoginForm($operator = null)
private function isLogged()
{
- return $this->getHttpSession()->get('_operator');
+ return $this->getSessionStorage()->get('_operator');
}
private function checkLogin()
@@ -73,12 +73,12 @@ public function checkLoginAction()
throw new UsernameNotFoundException('Invalid password');
}
- $this->getHttpSession()->set('_operator', $operator->getId());
+ $this->getSessionStorage()->set('_operator', $operator->getId());
$operator->setIsOnline(true);
$this->getDocumentManager()->persist($operator);
$this->getDocumentManager()->flush();
} catch (UsernameNotFoundException $e) {
- $this->getHttpSession()->setFlash('_error', $e->getMessage());
+ $this->getSessionStorage()->setFlash('_error', $e->getMessage());
return $this->redirect($this->generateUrl("_security_login", array(
'e' => __LINE__)));
}
@@ -97,7 +97,7 @@ public function indexAction()
public function loginAction()
{
- $errorMsg = $this->getHttpSession()->getFlash('_error');
+ $errorMsg = $this->getSessionStorage()->getFlash('_error');
$form = $this->createLoginForm();
return $this->renderTemplate('SGLiveChatBundle:Admin:login.html.twig', array(
@@ -113,7 +113,7 @@ public function logoutAction()
$this->getDocumentManager()->persist($operator);
$this->getDocumentManager()->flush();
- $this->getHttpSession()->remove('_operator');
+ $this->getSessionStorage()->remove('_operator');
}
if (!is_null($response = $this->checkLogin())) {
@@ -243,7 +243,7 @@ public function operatorsAction()
}
$operators = $this->getDocumentManager()->getRepository('SGLiveChatBundle:Operator')->findAll();
- $msg = $this->getHttpSession()->getFlash('msg', '');
+ $msg = $this->getSessionStorage()->getFlash('msg', '');
return $this->renderTemplate('SGLiveChatBundle:Admin:operators.html.twig', array(
'operators' => $operators,
'msg' => $msg));
@@ -274,7 +274,7 @@ public function operatorDepartmentAction($id = null)
$department->setIsActive(isset($params['isActive']) && $params['isActive']);
$this->getDocumentManager()->persist($department);
$this->getDocumentManager()->flush();
- $this->getHttpSession()->setFlash('msg', 'The department has been successfully updated');
+ $this->getSessionStorage()->setFlash('msg', 'The department has been successfully updated');
return $this->redirect($this->generateUrl('sglc_admin_operator_departments'));
}
@@ -294,7 +294,7 @@ public function operatorDepartmentsAction()
$this->checkLogin();
$departments = $this->getDocumentManager()->getRepository('SGLiveChatBundle:Operator\Department')->findAll();
- $msg = $this->getHttpSession()->getFlash('msg', '');
+ $msg = $this->getSessionStorage()->getFlash('msg', '');
return $this->renderTemplate('SGLiveChatBundle:Admin:operator-departments.html.twig', array(
'departments' => $departments,
@@ -331,7 +331,7 @@ public function operatorAction($id = null)
$operator->setIsActive(isset($params['isActive']) && $params['isActive']);
$this->getDocumentManager()->persist($operator);
$this->getDocumentManager()->flush();
- $this->getHttpSession()->setFlash('msg', 'The operator has been successfully updated');
+ $this->getSessionStorage()->setFlash('msg', 'The operator has been successfully updated');
return $this->redirect($this->generateUrl('sglc_admin_operators'));
}
View
8 src/ServerGrove/SGLiveChatBundle/Controller/BaseController.php
@@ -6,7 +6,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Cookie;
-use Symfony\Component\HttpFoundation\Session as HttpSession;
+use Symfony\Component\HttpFoundation\Session as SessionStorage;
use Doctrine\ODM\MongoDB\DocumentManager;
/**
@@ -44,7 +44,7 @@ public function getResponse()
/**
* @return Symfony\Component\HttpFoundation\Session
*/
- public function getHttpSession()
+ public function getSessionStorage()
{
if (is_null($this->session)) {
$this->session = $this->getRequest()->getSession();
@@ -85,10 +85,10 @@ public function redirect($url, $status = 302)
*/
protected function getOperator()
{
- if (!$this->getHttpSession()->has('_operator')) {
+ if (!$this->getSessionStorage()->has('_operator')) {
return null;
}
- return $this->getDocumentManager()->find('SGLiveChatBundle:Operator', $this->getHttpSession()->get('_operator'));
+ return $this->getDocumentManager()->find('SGLiveChatBundle:Operator', $this->getSessionStorage()->get('_operator'));
}
/**
View
52 src/ServerGrove/SGLiveChatBundle/Controller/ChatController.php
@@ -35,7 +35,7 @@ private function getChatSession($id)
*/
public function getChatSessionForCurrentUser()
{
- return $this->getChatSession($this->getHttpSession()->has('_operator') ? $this->getRequest()->get('id') : $this->getHttpSession()->get('chatsession'));
+ return $this->getChatSession($this->getSessionStorage()->has('_operator') ? $this->getRequest()->get('id') : $this->getSessionStorage()->get('chatsession'));
}
/**
@@ -48,8 +48,8 @@ private function getCannedMessages()
private function cacheUserForSession(User $user, Session $chatSession)
{
- $this->getHttpSession()->set('userId-' . $chatSession->getId(), $user->getId());
- $this->getHttpSession()->set('userKind-' . $chatSession->getId(), $user->getKind());
+ $this->getSessionStorage()->set('userId-' . $chatSession->getId(), $user->getId());
+ $this->getSessionStorage()->set('userKind-' . $chatSession->getId(), $user->getKind());
}
/**
@@ -58,12 +58,12 @@ private function cacheUserForSession(User $user, Session $chatSession)
*/
private function getUserForSession(Session $chatSession)
{
- if (!$this->getHttpSession()->has('userId-' . $chatSession->getId()) || !$this->getHttpSession()->has('userKind-' . $chatSession->getId())) {
+ if (!$this->getSessionStorage()->has('userId-' . $chatSession->getId()) || !$this->getSessionStorage()->has('userKind-' . $chatSession->getId())) {
throw new Exception('No user stored');
}
- $userId = $this->getHttpSession()->get('userId-' . $chatSession->getId());
- $userKind = $this->getHttpSession()->get('userKind-' . $chatSession->getId());
+ $userId = $this->getSessionStorage()->get('userId-' . $chatSession->getId());
+ $userKind = $this->getSessionStorage()->get('userKind-' . $chatSession->getId());
return $this->getDocumentManager()->find('SGLiveChatBundle:' . ($userKind == 'Guest' ? 'Visitor' : 'Operator'), $userId);
}
@@ -99,7 +99,7 @@ public function indexAction()
$this->getDocumentManager()->flush();
- $this->getHttpSession()->set('chatsession', $chatSession->getId());
+ $this->getSessionStorage()->set('chatsession', $chatSession->getId());
$this->cacheUserForSession($visitor, $chatSession);
return $this->redirect($this->generateUrl('sglc_chat_load', array(
@@ -108,15 +108,15 @@ public function indexAction()
return $this->renderTemplate('SGLiveChatBundle:Chat:index.html.twig', array(
'visitor' => $visitor,
- 'errorMsg' => $this->getHttpSession()->getFlash('errorMsg', null)));
+ 'errorMsg' => $this->getSessionStorage()->getFlash('errorMsg', null)));
}
public function inviteAction($sessId)
{
$operator = $this->getOperator();
if (!$operator) {
- $this->getHttpSession()->setFlash('errorMsg', 'Unauthorized access.');
+ $this->getSessionStorage()->setFlash('errorMsg', 'Unauthorized access.');
return $this->redirect($this->generateUrl('sglc_chat_homepage'));
}
@@ -152,13 +152,13 @@ public function inviteAction($sessId)
public function acceptInviteAction($id)
{
if (!($chatSession = $this->getChatSession($id))) {
- $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
+ $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
return $this->redirect($this->generateUrl('sglc_chat_homepage'));
}
if ($chatSession->getStatusId() != Session::STATUS_INVITE) {
- $this->getHttpSession()->setFlash('errorMsg', 'Invitation has expired or canceled. You can start a new chat now.');
+ $this->getSessionStorage()->setFlash('errorMsg', 'Invitation has expired or canceled. You can start a new chat now.');
return $this->redirect($this->generateUrl('sglc_chat_homepage'));
}
@@ -172,7 +172,7 @@ public function acceptInviteAction($id)
public function rejectInviteAction($id)
{
if (!($chatSession = $this->getChatSession($id))) {
- $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
+ $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
return $this->getResponse();
}
@@ -187,13 +187,13 @@ public function acceptAction($id)
$operator = $this->getOperator();
if (!$operator) {
- $this->getHttpSession()->setFlash('errorMsg', 'Unauthorized access.');
+ $this->getSessionStorage()->setFlash('errorMsg', 'Unauthorized access.');
return $this->redirect($this->generateUrl('sglc_chat_homepage'));
}
if (!($chatSession = $this->getChatSession($id))) {
- $this->getHttpSession()->setFlash('errorMsg', 'Chat not found');
+ $this->getSessionStorage()->setFlash('errorMsg', 'Chat not found');
return $this->redirect($this->generateUrl('sglc_chat_homepage'));
}
@@ -228,7 +228,7 @@ public function loadAction()
{
$operator = $this->getOperator();
if (!($chatSession = $this->getChatSessionForCurrentUser())) {
- $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
+ $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
return $this->redirect($this->generateUrl('sglc_chat_homepage'));
}
@@ -245,9 +245,9 @@ public function loadAction()
}
}
- $this->getHttpSession()->set('chatStatus' . $chatSession->getId(), '');
+ $this->getSessionStorage()->set('chatStatus' . $chatSession->getId(), '');
- $this->getHttpSession()->set('lastMessage', 0);
+ $this->getSessionStorage()->set('lastMessage', 0);
$user = $this->getUserForSession($chatSession);
return $this->renderTemplate('SGLiveChatBundle:Chat:load.html.twig', array(
@@ -272,7 +272,7 @@ public function sendAction($id)
}
if (!$chatSession = $this->getChatSession($id)) {
- $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
+ $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
return $this->redirect($this->generateUrl('sglc_chat_homepage'));
}
@@ -306,12 +306,12 @@ public function messagesAction($_format)
$this->getDocumentManager()->persist($chatSession);
$this->getDocumentManager()->flush();
- if ($this->getHttpSession()->has('lastMessage')) {
- $last = $this->getHttpSession()->get('lastMessage');
+ if ($this->getSessionStorage()->has('lastMessage')) {
+ $last = $this->getSessionStorage()->get('lastMessage');
} else {
$last = 0;
}
- $this->getHttpSession()->set('lastMessage', count($messages));
+ $this->getSessionStorage()->set('lastMessage', count($messages));
if ($last) {
$messages = array_slice($messages->toArray(), $last);
@@ -346,7 +346,7 @@ public function messagesAction($_format)
public function doneAction()
{
if (!$chatSession = $this->getChatSessionForCurrentUser()) {
- $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
+ $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
return $this->redirect($this->generateUrl('sglc_chat_homepage'));
}
@@ -397,23 +397,23 @@ public function statusAction()
}
if (!$chatSession = $this->getChatSessionForCurrentUser()) {
- $this->getHttpSession()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
+ $this->getSessionStorage()->setFlash('errorMsg', 'No chat found. Session may have expired. Please start again.');
$this->getResponse()->headers->set('Content-type', 'text/javascript');
$this->getResponse()->setContent(sprintf('location.href = %s;', var_export($this->generateUrl('sglc_chat_homepage'), true)));
return $this->getResponse();
}
- if ($chatSession->getOperator() && $chatSession->getStatusId() == Session::STATUS_IN_PROGRESS && $this->getHttpSession()->get('chatStatus' . $chatSession->getId()) != 'started') {
- $this->getHttpSession()->set('chatStatus' . $chatSession->getId(), 'started');
+ if ($chatSession->getOperator() && $chatSession->getStatusId() == Session::STATUS_IN_PROGRESS && $this->getSessionStorage()->get('chatStatus' . $chatSession->getId()) != 'started') {
+ $this->getSessionStorage()->set('chatStatus' . $chatSession->getId(), 'started');
$this->getResponse()->headers->set('Content-type', 'text/javascript');
$this->getResponse()->setContent('Chat.get().start();');
return $this->getResponse();
}
if ($chatSession->getStatusId() == Session::STATUS_CLOSED || $chatSession->getStatusId() == Session::STATUS_CANCELED) {
- $this->getHttpSession()->setFlash('errorMsg', 'Chat has been ' . $chatSession->getStatus());
+ $this->getSessionStorage()->setFlash('errorMsg', 'Chat has been ' . $chatSession->getStatus());
$this->getResponse()->headers->set('Content-type', 'text/javascript');
$this->getResponse()->setContent(sprintf('location.href = %s;', var_export($this->generateUrl('sglc_chat_homepage'), true)));
View
8 src/ServerGrove/SGLiveChatBundle/Controller/TrackController.php
@@ -61,17 +61,17 @@ public function updateAction()
/* @var $chat \ServerGrove\SGLiveChatBundle\Document\Session */
$chat = current($chats);
- if (!$this->getHttpSession()->get('chat_invite', null)) {
- $this->getHttpSession()->set('chat_invite', $chat->getId());
+ if (!$this->getSessionStorage()->get('chat_invite', null)) {
+ $this->getSessionStorage()->set('chat_invite', $chat->getId());
}
$this->getResponse()->headers->set('Content-type', 'text/javascript');
return $this->renderTemplate('SGLiveChatBundle:Track:create-invite-box.js.twig', array(
'chat' => $chat));
} else {
- if ($this->getHttpSession()->get('chat_invite')) {
- $this->getHttpSession()->set('chat_invite', null);
+ if ($this->getSessionStorage()->get('chat_invite')) {
+ $this->getSessionStorage()->set('chat_invite', null);
$this->getResponse()->headers->set('Content-type', 'text/javascript');

0 comments on commit 62e3780

Please sign in to comment.