[HttpFoundation][FrameworkBundle] Keep save auto_start behaviour as in 2.2 and make component values consistent with FrameworkBundle's configuration options.

This commit is contained in:
Drak 2013-04-06 17:57:34 +01:00
parent ceaf69b32e
commit 2583c2614f
5 changed files with 15 additions and 27 deletions

View File

@ -9,8 +9,7 @@ CHANGELOG
* added `TimedPhpEngine`
* added `--clean` option the the `translation:update` command
* added `http_method_override` option
* Reintroduce `auto_start` session config flag which control to `SessionListener` to manually start sessions
during framework request cycle.
* Reintroduce `auto_start` session config flag to instruct the `SessionListener` to manually start session
* Added session config option `on_demand_mode` to control session start on demand.
2.2.0

View File

@ -185,7 +185,7 @@ class Configuration implements ConfigurationInterface
->canBeUnset()
->children()
->booleanNode('auto_start')
->defaultTrue()
->defaultFalse()
->info('Flag for SessionListener to start session')
->end()
->enumNode('on_demand_mode')

View File

@ -319,18 +319,7 @@ class FrameworkExtension extends Extension
$container->setParameter('session.auto_start', $config['auto_start']);
// this controls the session start on demand feature
switch ($config['on_demand_mode']) {
// already validated
case 'on':
$demand = SessionStorageInterface::START_ON_DEMAND;
break;
case 'off':
$demand = SessionStorageInterface::NO_START_ON_DEMAND_STRICT;
break;
case 'off_lax':
$demand = SessionStorageInterface::NO_START_ON_DEMAND_LAX;
}
$container->setParameter('session.storage.on_demand_mode', $demand);
$container->setParameter('session.storage.on_demand_mode', $config['on_demand_mode']);
$container->setParameter('session.storage.mock_name', $config['mock_name']);

View File

@ -31,7 +31,7 @@ class SessionListener implements EventSubscriberInterface
private $container;
private $autoStart;
public function __construct(ContainerInterface $container, $autoStart)
public function __construct(ContainerInterface $container, $autoStart = false)
{
$this->container = $container;
$this->autoStart = $autoStart;

View File

@ -28,24 +28,24 @@ interface SessionStorageInterface
* Do not start session on demand and throw exception if attempt
* is make to read or write bag data.
*/
const NO_START_ON_DEMAND_STRICT = 0;
const NO_START_ON_DEMAND_STRICT = 'off';
/**
* Start the session on demand when accessing bag data.
*/
const START_ON_DEMAND = 1;
const START_ON_DEMAND = 'on';
/**
* Do not start session on demand but allow access to session bags.
*/
const NO_START_ON_DEMAND_LAX = 2;
const NO_START_ON_DEMAND_LAX = 'off_lax';
/**
* Starts the session.
*
* @throws \RuntimeException If something goes wrong starting the session.
* @throws \RuntimeException If something goes wrong starting the session
*
* @return boolean True if started.
* @return boolean True if started
*
* @api
*/
@ -54,14 +54,14 @@ interface SessionStorageInterface
/**
* Checks if the session is started.
*
* @return boolean True if started, false otherwise.
* @return boolean True if started, false otherwise
*/
public function isStarted();
/**
* Returns the session ID
*
* @return string The session ID or empty.
* @return string The session ID or empty
*
* @api
*/
@ -79,7 +79,7 @@ interface SessionStorageInterface
/**
* Returns the session name
*
* @return mixed The session name.
* @return mixed The session name
*
* @api
*/
@ -105,11 +105,11 @@ interface SessionStorageInterface
* Note regenerate+destroy should not clear the session data in memory
* only delete the session data from persistent storage.
*
* @param Boolean $destroy Destroy session when regenerating?
* @param Boolean $destroy Flag true to destroy session when regenerating
* @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
* will leave the system settings unchanged, 0 sets the cookie
* to expire with browser session. Time is in seconds, and is
* not a Unix timestamp.
* not a Unix timestamp
*
* @return Boolean True if session regenerated, false if error
*
@ -128,7 +128,7 @@ interface SessionStorageInterface
* it should actually persist the session data if required.
*
* @throws \RuntimeException If the session is saved without being started, or if the session
* is already closed.
* is already closed
*/
public function save();