session handler config upd

This commit is contained in:
Milos Stojanovic
2019-06-19 09:23:20 +02:00
parent 0765079a26
commit 5da41e63c9
7 changed files with 28 additions and 46 deletions

View File

@@ -30,7 +30,7 @@ class SessionStorage implements Service, SessionStorageInterface
{
// we don't have a previous session attached
if (! $this->getSession()) {
$handler = $config['available'][$config['session_handler']];
$handler = $config['handler'];
$session = new Session($handler());
$session->setName('filegator');

View File

@@ -32,9 +32,7 @@ return [
'Filegator\Services\Session\SessionStorageInterface' => [
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
'config' => [
'session_handler' => 'filesession',
'available' => [
'filesession' => function () {
'handler' => function () {
$save_path = null; // use default system path
//$save_path = __DIR__.'/private/sessions';
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler($save_path);
@@ -43,7 +41,6 @@ return [
},
],
],
],
'Filegator\Services\Cors\Cors' => [
'handler' => '\Filegator\Services\Cors\Cors',
'config' => [

View File

@@ -21,4 +21,4 @@ Default handler will use simple ```/private/logs/app.log``` file to store applic
],
```
There are many different handlers you can use. Some of them are listed [here](https://github.com/Seldaek/monolog#documentation).
There are many different handlers you can add ot top of the stack (monolog_handlers array). Some of them are listed [here](https://github.com/Seldaek/monolog#documentation).

View File

@@ -18,9 +18,7 @@ Then, open ```configuration.php``` and update Session handler to:
'Filegator\Services\Session\SessionStorageInterface' => [
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
'config' => [
'session_handler' => 'database',
'available' => [
'database' => function () {
'handler' => function () {
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
'mysql://root:password@localhost:3360/filegator'
);
@@ -29,7 +27,6 @@ Then, open ```configuration.php``` and update Session handler to:
},
],
],
],
```
Don't forget to enter correct database details.
@@ -43,9 +40,7 @@ For example you can pass ```cookie_lifetime``` parameter to extend default sessi
'Filegator\Services\Session\SessionStorageInterface' => [
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
'config' => [
'session_handler' => 'database',
'available' => [
'database' => function () {
'handler' => function () {
$handler = new \Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler(
'mysql://root:password@localhost:3360/filegator'
);
@@ -56,6 +51,5 @@ For example you can pass ```cookie_lifetime``` parameter to extend default sessi
},
],
],
],
```

View File

@@ -25,12 +25,9 @@ abstract class AuthTest extends TestCase
{
$this->session = new SessionStorage(new Request());
$this->session->init([
'session_handler' => 'mockfilesession',
'available' => [
'mockfilesession' => function () {
'handler' => function () {
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
},
],
]);
$this->setAuth();

View File

@@ -25,12 +25,9 @@ class SessionStorageTest extends TestCase
{
$this->session_service = new SessionStorage(new Request());
$this->session_service->init([
'session_handler' => 'mockfilesession',
'available' => [
'mockfilesession' => function () {
'handler' => function () {
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
},
],
]);
parent::setUp();

View File

@@ -28,14 +28,11 @@ return [
'Filegator\Services\Session\SessionStorageInterface' => [
'handler' => '\Filegator\Services\Session\Adapters\SessionStorage',
'config' => [
'session_handler' => 'mockfilesession',
'available' => [
'mockfilesession' => function () {
'handler' => function () {
return new \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage();
},
],
],
],
'Filegator\Services\Tmpfs\TmpfsInterface' => [
'handler' => '\Filegator\Services\Tmpfs\Adapters\Tmpfs',
'config' => [