From 78289f12401a74a0feede62890e1e9cd0fe12bf5 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 17 Nov 2017 10:02:01 +0100 Subject: [PATCH] Updated the session/* articles for Symfony 4 --- session.rst | 9 +++++++-- session/limit_metadata_writes.rst | 3 +++ session/locale_sticky_session.rst | 18 ++++++++++-------- session/php_bridge.rst | 6 ++++++ session/proxy_examples.rst | 6 +++--- session/sessions_directory.rst | 6 +++--- 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/session.rst b/session.rst index 144f068d34f..33fbbc61745 100644 --- a/session.rst +++ b/session.rst @@ -3,6 +3,11 @@ Sessions .. toctree:: :maxdepth: 1 - :glob: - session/* + session/sessions_directory + session/avoid_session_start + session/locale_sticky_session + session/limit_metadata_writes + session/php_bridge + session/proxy_examples + diff --git a/session/limit_metadata_writes.rst b/session/limit_metadata_writes.rst index de28ccb52a8..ea9b95c9d4a 100644 --- a/session/limit_metadata_writes.rst +++ b/session/limit_metadata_writes.rst @@ -23,12 +23,14 @@ than zero: .. code-block:: yaml + # config/packages/framework.yaml framework: session: metadata_update_threshold: 120 .. code-block:: xml + loadFromExtension('framework', array( 'session' => array( 'metadata_update_threshold' => 120, diff --git a/session/locale_sticky_session.rst b/session/locale_sticky_session.rst index 7a4ae4307cd..9280f8360d5 100644 --- a/session/locale_sticky_session.rst +++ b/session/locale_sticky_session.rst @@ -73,16 +73,18 @@ via some "Change Locale" route & controller), or create a route with a the :ref: .. code-block:: yaml + # config/services.yaml services: # ... App\EventSubscriber\LocaleSubscriber: arguments: ['%kernel.default_locale%'] - # redundant if you're using autoconfigure - tags: [kernel.event_subscriber] + # uncomment the next line if you are not using autoconfigure + # tags: [kernel.event_subscriber] .. code-block:: xml + %kernel.default_locale% - + + .. code-block:: php + // config/services.php use App\EventSubscriber\LocaleSubscriber; $container->register(LocaleSubscriber::class) ->addArgument('%kernel.default_locale%') - ->addTag('kernel.event_subscriber'); + // uncomment the next line if you are not using autoconfigure + // ->addTag('kernel.event_subscriber'); That's it! Now celebrate by changing the user's locale and seeing that it's sticky throughout the request. @@ -115,7 +120,7 @@ method:: // from a controller... use Symfony\Component\HttpFoundation\Request; - public function indexAction(Request $request) + public function index(Request $request) { $locale = $request->getLocale(); } @@ -159,9 +164,6 @@ event: $this->session = $session; } - /** - * @param InteractiveLoginEvent $event - */ public function onInteractiveLogin(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); diff --git a/session/php_bridge.rst b/session/php_bridge.rst index f8c161f3ec6..4771fe67e39 100644 --- a/session/php_bridge.rst +++ b/session/php_bridge.rst @@ -15,6 +15,7 @@ for the ``handler_id``: .. code-block:: yaml + # config/packages/framework.yaml framework: session: storage_id: session.storage.php_bridge @@ -22,6 +23,7 @@ for the ``handler_id``: .. code-block:: xml + loadFromExtension('framework', array( 'session' => array( 'storage_id' => 'session.storage.php_bridge', @@ -54,6 +57,7 @@ the example below: .. code-block:: yaml + # config/packages/framework.yaml framework: session: storage_id: session.storage.php_bridge @@ -61,6 +65,7 @@ the example below: .. code-block:: xml + loadFromExtension('framework', array( 'session' => array( 'storage_id' => 'session.storage.php_bridge', diff --git a/session/proxy_examples.rst b/session/proxy_examples.rst index 82f636b7616..2a475cc25c5 100644 --- a/session/proxy_examples.rst +++ b/session/proxy_examples.rst @@ -21,7 +21,7 @@ Symfony to use your session handler instead of the default one: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: session: # ... @@ -29,7 +29,7 @@ Symfony to use your session handler instead of the default one: .. code-block:: xml - + loadFromExtension('framework', array( // ... diff --git a/session/sessions_directory.rst b/session/sessions_directory.rst index c1b91f5472f..9e8d06ea627 100644 --- a/session/sessions_directory.rst +++ b/session/sessions_directory.rst @@ -11,7 +11,7 @@ this path, update the ``framework.session.save_path`` configuration key: .. code-block:: yaml - # app/config/config.yml + # config/packages/framework.yaml framework: session: handler_id: session.handler.native_file @@ -19,7 +19,7 @@ this path, update the ``framework.session.save_path`` configuration key: .. code-block:: xml - + loadFromExtension('framework', array( 'session' => array( 'handler_id' => 'session.handler.native_file',