-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iaejean custom http session #120
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
namespace Ding\HttpSession\Exception; | ||
|
||
class HttpSessionException extends \Exception | ||
{ | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
namespace Ding\HttpSession; | ||
|
||
interface IHttpSession | ||
{ | ||
public function destroy(); | ||
|
||
public function hasAttribute($name); | ||
|
||
public function getAttribute($name); | ||
|
||
public function setAttribute($name, $value); | ||
|
||
public function getSession(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method is still defined as static in HttpSession... are you sure you ran the tests and they pass? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,13 +27,12 @@ | |
*/ | ||
namespace Ding\Mvc\Http; | ||
|
||
use Ding\HttpSession\HttpSession; | ||
|
||
use Ding\MessageSource\IMessageSource; | ||
|
||
use Ding\MessageSource\IMessageSourceAware; | ||
use Ding\Mvc\IViewRender; | ||
use Ding\Mvc\View; | ||
use Ding\Container\Impl\ContainerImpl; | ||
|
||
/** | ||
* Http view render. | ||
|
@@ -60,16 +59,18 @@ public function setMessageSource(IMessageSource $messageSource) | |
|
||
public function translate($bundle, $message, $arguments = array()) | ||
{ | ||
$session = HttpSession::getSession(); | ||
if (!$session->hasAttribute('LANGUAGE')) { | ||
return $this->messageSource->getMessage( | ||
$bundle, $message, $arguments | ||
); | ||
} else { | ||
return $this->messageSource->getMessage( | ||
$bundle, $message, $arguments, $session->getAttribute('LANGUAGE') | ||
); | ||
} | ||
$container = ContainerImpl::getInstance(); | ||
$session = $container->getBean('SessionHandler'); | ||
|
||
if (!$session->hasAttribute('LANGUAGE')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Identation seems to be wrong here, can you make it 4 spaces? :) |
||
return $this->messageSource->getMessage( | ||
$bundle, $message, $arguments | ||
); | ||
} else { | ||
return $this->messageSource->getMessage( | ||
$bundle, $message, $arguments, $session->getAttribute('LANGUAGE') | ||
); | ||
} | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans> | ||
<bean id="sesionHandler" scope="singleton" class="Ding\HttpSession\HttpSession" /> | ||
</beans> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this exception thrown? Doesn't seem to be used at all