Commit 0c53df76 authored by Fabien Potencier's avatar Fabien Potencier

feature #1179 refactored the session provider (fabpot)

This PR was merged into the 2.0.x-dev branch.

Discussion
----------

refactored the session provider

replaces #934 by making possible to override the default bags, but more importantly, it removes the storage definition from the inside of the session one to the outside.

Commits
-------

2cb76057 refactored the session provider
parents cfb6ed09 2cb76057
...@@ -38,15 +38,15 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -38,15 +38,15 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP
$app['session.test'] = false; $app['session.test'] = false;
$app['session'] = function ($app) { $app['session'] = function ($app) {
if (!isset($app['session.storage'])) { return new Session($app['session.storage']);
if ($app['session.test']) { };
$app['session.storage'] = $app['session.storage.test'];
} else { $app['session.storage'] = function ($app) {
$app['session.storage'] = $app['session.storage.native']; if ($app['session.test']) {
} return $app['session.storage.test'];
} }
return new Session($app['session.storage']); return $app['session.storage.native'];
}; };
$app['session.storage.handler'] = function ($app) { $app['session.storage.handler'] = function ($app) {
...@@ -61,7 +61,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -61,7 +61,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP
}; };
$app['session.listener'] = function ($app) { $app['session.listener'] = function ($app) {
return new SessionListener($app); return new SessionListener($app, $app['session.attribute_bag'], $app['session.flash_bag']);
}; };
$app['session.storage.test'] = function () { $app['session.storage.test'] = function () {
...@@ -75,6 +75,8 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -75,6 +75,8 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP
$app['session.storage.options'] = array(); $app['session.storage.options'] = array();
$app['session.default_locale'] = 'en'; $app['session.default_locale'] = 'en';
$app['session.storage.save_path'] = null; $app['session.storage.save_path'] = null;
$app['session.attribute_bag'] = null;
$app['session.flash_bag'] = null;
} }
public function subscribe(Container $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment