[FrameworkBundle] Add session.handler service and handler_id configuration property.
Revert service back to session.storage.native Rename session.storage.native_file to session.handler.native_file (which is the default so no BC break from 2.0)
This commit is contained in:
parent
130831248d
commit
a1c678ecd7
@ -167,7 +167,8 @@ class Configuration implements ConfigurationInterface
|
|||||||
->canBeUnset()
|
->canBeUnset()
|
||||||
->children()
|
->children()
|
||||||
->booleanNode('auto_start')->defaultFalse()->end()
|
->booleanNode('auto_start')->defaultFalse()->end()
|
||||||
->scalarNode('storage_id')->defaultValue('session.storage.native_file')->end()
|
->scalarNode('storage_id')->defaultValue('session.storage.native')->end()
|
||||||
|
->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end()
|
||||||
->scalarNode('name')->end()
|
->scalarNode('name')->end()
|
||||||
->scalarNode('cookie_lifetime')->end()
|
->scalarNode('cookie_lifetime')->end()
|
||||||
->scalarNode('cookie_path')->end()
|
->scalarNode('cookie_path')->end()
|
||||||
|
@ -310,10 +310,16 @@ class FrameworkExtension extends Extension
|
|||||||
}
|
}
|
||||||
$container->setParameter('session.storage.options', $options);
|
$container->setParameter('session.storage.options', $options);
|
||||||
|
|
||||||
|
// session handler (the internal callback registered with PHP session management)
|
||||||
|
$container->setAlias('session.handler', $config['handler_id']);
|
||||||
|
|
||||||
$this->addClassesToCompile(array(
|
$this->addClassesToCompile(array(
|
||||||
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
|
'Symfony\\Bundle\\FrameworkBundle\\EventListener\\SessionListener',
|
||||||
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface',
|
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface',
|
||||||
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\AbstractSessionStorage',
|
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorage',
|
||||||
|
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\NativeSessionHandler',
|
||||||
|
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\AbstractProxy',
|
||||||
|
'Symfony\\Component\\HttpFoundation\\Session\\Storage\\Proxy\SessionHandlerProxy',
|
||||||
$container->getDefinition('session')->getClass(),
|
$container->getDefinition('session')->getClass(),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
|
|
||||||
<xsd:complexType name="session">
|
<xsd:complexType name="session">
|
||||||
<xsd:attribute name="storage-id" type="xsd:string" />
|
<xsd:attribute name="storage-id" type="xsd:string" />
|
||||||
|
<xsd:attribute name="handler-id" type="xsd:string" />
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
<xsd:attribute name="cookie-lifetime" type="xsd:integer" />
|
<xsd:attribute name="cookie-lifetime" type="xsd:integer" />
|
||||||
<xsd:attribute name="cookie-path" type="xsd:string" />
|
<xsd:attribute name="cookie-path" type="xsd:string" />
|
||||||
|
@ -8,8 +8,9 @@
|
|||||||
<parameter key="session.class">Symfony\Component\HttpFoundation\Session\Session</parameter>
|
<parameter key="session.class">Symfony\Component\HttpFoundation\Session\Session</parameter>
|
||||||
<parameter key="session.flashbag.class">Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag</parameter>
|
<parameter key="session.flashbag.class">Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag</parameter>
|
||||||
<parameter key="session.attribute_bag.class">Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag</parameter>
|
<parameter key="session.attribute_bag.class">Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag</parameter>
|
||||||
<parameter key="session.storage.native_file.class">Symfony\Component\HttpFoundation\Session\Storage\NativeFileSessionStorage</parameter>
|
<parameter key="session.storage.native.class">Symfony\Component\HttpFoundation\Session\Storage\SessionStorage</parameter>
|
||||||
<parameter key="session.storage.mock_file.class">Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage</parameter>
|
<parameter key="session.storage.mock_file.class">Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage</parameter>
|
||||||
|
<parameter key="session.handler.native_file.class">Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler</parameter>
|
||||||
<parameter key="session_listener.class">Symfony\Bundle\FrameworkBundle\EventListener\SessionListener</parameter>
|
<parameter key="session_listener.class">Symfony\Bundle\FrameworkBundle\EventListener\SessionListener</parameter>
|
||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
@ -20,18 +21,21 @@
|
|||||||
<argument type="service" id="session.flash_bag" />
|
<argument type="service" id="session.flash_bag" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<service id="session.storage.native" class="%session.storage.native.class%">
|
||||||
|
<argument>%session.storage.options%</argument>
|
||||||
|
<argument type="service" id="session.handler" />
|
||||||
|
</service>
|
||||||
|
|
||||||
<service id="session.flash_bag" class="%session.flashbag.class%" public="false" />
|
<service id="session.flash_bag" class="%session.flashbag.class%" public="false" />
|
||||||
|
|
||||||
<service id="session.attribute_bag" class="%session.attribute_bag.class%" public="false" />
|
<service id="session.attribute_bag" class="%session.attribute_bag.class%" public="false" />
|
||||||
|
|
||||||
<service id="session.storage.mock_file" class="%session.storage.mock_file.class%" public="false">
|
<service id="session.storage.mock_file" class="%session.storage.mock_file.class%" public="false">
|
||||||
<argument>%kernel.cache_dir%/sessions</argument>
|
<argument>%kernel.cache_dir%/sessions</argument>
|
||||||
<argument>%session.storage.options%</argument>
|
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="session.storage.native_file" class="%session.storage.native_file.class%" public="false">
|
<service id="session.handler.native_file" class="%session.handler.native_file.class%" public="false">
|
||||||
<argument>%kernel.cache_dir%/sessions</argument>
|
<argument>%kernel.cache_dir%/sessions</argument>
|
||||||
<argument>%session.storage.options%</argument>
|
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="session_listener" class="%session_listener.class%">
|
<service id="session_listener" class="%session_listener.class%">
|
||||||
@ -40,7 +44,6 @@
|
|||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- for BC -->
|
<!-- for BC -->
|
||||||
<service id="session.storage.native" alias="session.storage.native_file" />
|
|
||||||
<service id="session.storage.filesystem" alias="session.storage.mock_file" />
|
<service id="session.storage.filesystem" alias="session.storage.mock_file" />
|
||||||
</services>
|
</services>
|
||||||
</container>
|
</container>
|
||||||
|
@ -4,7 +4,8 @@ $container->loadFromExtension('framework', array(
|
|||||||
'secret' => 's3cr3t',
|
'secret' => 's3cr3t',
|
||||||
'session' => array(
|
'session' => array(
|
||||||
'auto_start' => true,
|
'auto_start' => true,
|
||||||
'storage_id' => 'session.storage.native_file',
|
'storage_id' => 'session.storage.native',
|
||||||
|
'handler_id' => 'session.handler.native_file',
|
||||||
'name' => '_SYMFONY',
|
'name' => '_SYMFONY',
|
||||||
'lifetime' => 2012,
|
'lifetime' => 2012,
|
||||||
'path' => '/sf2',
|
'path' => '/sf2',
|
||||||
|
@ -4,7 +4,8 @@ $container->loadFromExtension('framework', array(
|
|||||||
'secret' => 's3cr3t',
|
'secret' => 's3cr3t',
|
||||||
'session' => array(
|
'session' => array(
|
||||||
'auto_start' => true,
|
'auto_start' => true,
|
||||||
'storage_id' => 'session.storage.native_file',
|
'storage_id' => 'session.storage.native',
|
||||||
|
'handler_id' => 'session.handler.native_file',
|
||||||
'name' => '_SYMFONY',
|
'name' => '_SYMFONY',
|
||||||
'lifetime' => 2012,
|
'lifetime' => 2012,
|
||||||
'path' => '/sf2',
|
'path' => '/sf2',
|
||||||
|
@ -20,7 +20,8 @@ $container->loadFromExtension('framework', array(
|
|||||||
),
|
),
|
||||||
'session' => array(
|
'session' => array(
|
||||||
'auto_start' => true,
|
'auto_start' => true,
|
||||||
'storage_id' => 'session.storage.native_file',
|
'storage_id' => 'session.storage.native',
|
||||||
|
'handler_id' => 'session.handler.native_file',
|
||||||
'name' => '_SYMFONY',
|
'name' => '_SYMFONY',
|
||||||
'lifetime' => 86400,
|
'lifetime' => 86400,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||||
|
|
||||||
<framework:config secret="s3cr3t">
|
<framework:config secret="s3cr3t">
|
||||||
<framework:session auto-start="true" storage-id="session.storage.native_file" name="_SYMFONY" lifetime="2012" path="/sf2" domain="sf2.example.com" secure="false" httponly="false" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" />
|
<framework:session auto-start="true" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" lifetime="2012" path="/sf2" domain="sf2.example.com" secure="false" httponly="false" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" />
|
||||||
</framework:config>
|
</framework:config>
|
||||||
</container>
|
</container>
|
||||||
|
@ -7,6 +7,6 @@
|
|||||||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
|
||||||
|
|
||||||
<framework:config secret="s3cr3t">
|
<framework:config secret="s3cr3t">
|
||||||
<framework:session auto-start="true" storage-id="session.storage.native_file" name="_SYMFONY" lifetime="2012" path="/sf2" domain="sf2.example.com" secure="false" httponly="false" cookie-lifetime="86400" cookie-path="/" cookie-httponly="true" />
|
<framework:session auto-start="true" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" lifetime="2012" path="/sf2" domain="sf2.example.com" secure="false" httponly="false" cookie-lifetime="86400" cookie-path="/" cookie-httponly="true" />
|
||||||
</framework:config>
|
</framework:config>
|
||||||
</container>
|
</container>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<framework:esi enabled="true" />
|
<framework:esi enabled="true" />
|
||||||
<framework:profiler only-exceptions="true" />
|
<framework:profiler only-exceptions="true" />
|
||||||
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
|
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
|
||||||
<framework:session auto-start="true" storage-id="session.storage.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" />
|
<framework:session auto-start="true" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="true" />
|
||||||
<framework:templating assets-version="SomeVersionScheme" cache="/path/to/cache" >
|
<framework:templating assets-version="SomeVersionScheme" cache="/path/to/cache" >
|
||||||
<framework:loader>loader.foo</framework:loader>
|
<framework:loader>loader.foo</framework:loader>
|
||||||
<framework:loader>loader.bar</framework:loader>
|
<framework:loader>loader.bar</framework:loader>
|
||||||
|
@ -2,7 +2,8 @@ framework:
|
|||||||
secret: s3cr3t
|
secret: s3cr3t
|
||||||
session:
|
session:
|
||||||
auto_start: true
|
auto_start: true
|
||||||
storage_id: session.storage.native_file
|
storage_id: session.storage.native
|
||||||
|
handler_id: session.handler.native_file
|
||||||
name: _SYMFONY
|
name: _SYMFONY
|
||||||
lifetime: 2012
|
lifetime: 2012
|
||||||
path: /sf2
|
path: /sf2
|
||||||
|
@ -2,7 +2,8 @@ framework:
|
|||||||
secret: s3cr3t
|
secret: s3cr3t
|
||||||
session:
|
session:
|
||||||
auto_start: true
|
auto_start: true
|
||||||
storage_id: session.storage.native_file
|
storage_id: session.storage.native
|
||||||
|
handler_id: session.handler.native_file
|
||||||
name: _SYMFONY
|
name: _SYMFONY
|
||||||
lifetime: 2012
|
lifetime: 2012
|
||||||
path: /sf2
|
path: /sf2
|
||||||
|
@ -14,7 +14,8 @@ framework:
|
|||||||
type: xml
|
type: xml
|
||||||
session:
|
session:
|
||||||
auto_start: true
|
auto_start: true
|
||||||
storage_id: session.storage.native_file
|
storage_id: session.storage.native
|
||||||
|
handler_id: session.handler.native_file
|
||||||
name: _SYMFONY
|
name: _SYMFONY
|
||||||
lifetime: 86400
|
lifetime: 86400
|
||||||
path: /
|
path: /
|
||||||
|
@ -78,7 +78,8 @@ abstract class FrameworkExtensionTest extends TestCase
|
|||||||
$this->assertTrue($container->hasDefinition('session'), '->registerSessionConfiguration() loads session.xml');
|
$this->assertTrue($container->hasDefinition('session'), '->registerSessionConfiguration() loads session.xml');
|
||||||
$this->assertEquals('fr', $container->getParameter('kernel.default_locale'));
|
$this->assertEquals('fr', $container->getParameter('kernel.default_locale'));
|
||||||
$this->assertTrue($container->getDefinition('session_listener')->getArgument(1));
|
$this->assertTrue($container->getDefinition('session_listener')->getArgument(1));
|
||||||
$this->assertEquals('session.storage.native_file', (string) $container->getAlias('session.storage'));
|
$this->assertEquals('session.storage.native', (string) $container->getAlias('session.storage'));
|
||||||
|
$this->assertEquals('session.handler.native_file', (string) $container->getAlias('session.handler'));
|
||||||
|
|
||||||
$options = $container->getParameter('session.storage.options');
|
$options = $container->getParameter('session.storage.options');
|
||||||
$this->assertEquals('_SYMFONY', $options['name']);
|
$this->assertEquals('_SYMFONY', $options['name']);
|
||||||
|
Reference in New Issue
Block a user