Skip to content

Commit

Permalink
Merge pull request #1981 from alchemy-fr/feature/native-session-handler
Browse files Browse the repository at this point in the history
PHRAS-1236 Enable native session handlers
  • Loading branch information
aztech-dev committed Nov 24, 2016
2 parents 381d52f + c87325e commit 1955798
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Alchemy/Phrasea/Application.php
Expand Up @@ -131,6 +131,7 @@
use Silex\Provider\ServiceControllerServiceProvider;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeSessionHandler;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Unoconv\UnoconvServiceProvider;
Expand Down Expand Up @@ -300,6 +301,15 @@ public function __construct($environment = self::ENV_PROD)
'session.test' => $this->getEnvironment() === static::ENV_TEST,
'session.storage.options' => array('cookie_lifetime' => 0)
));

$this['session.storage.handler'] = $this->extend('session.storage.handler', function ($sessionHandler) {
if (ini_get('session.save_handler') == 'files') {
return $sessionHandler;
}

return new NativeSessionHandler();
});

$this['session.storage.test'] = $this->share(function ($app) {
return new MockArraySessionStorage();
});
Expand Down

0 comments on commit 1955798

Please sign in to comment.