-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Added docs for the SessionValueResolver #7322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
controller.rst
Outdated
|
||
use Symfony\Component\HttpFoundation\Request; | ||
.. versionadded:: 3.3 | ||
The ability to request a ``Session`` in actions was introduced in Symfony 3. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3.3
a9e707d
to
c1be8a1
Compare
Rebased and addressed the remark. @xabbuh I forgot to link to this PR in the feature PR, but now that it's merged, the |
controller.rst
Outdated
|
||
public function indexAction(Session $session) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using SessionInterface
instead?
controller.rst
Outdated
public function indexAction(Request $request) | ||
{ | ||
$session = $request->getSession(); | ||
To retrieve the session, add the :class:`Symfony\\Component\\HttpFoundation\\Session\\Session` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about:
"To retrieve the session, type hint a controller argument with :class:Symfony\\Component\\HttpFoundation\\Session\\SessionInterface
or any implementation:"
?
Then keep the example below which is much more useful to get access to method not available through the interface.
c1be8a1
to
3be2287
Compare
I've addressed the comments and added a small example of how to use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This one is not on hold anymore, symfony/symfony#21164 is merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Left 2 minor comments that can be applied during the merge.
Every ``SessionInterface`` implementation is supported. If you have your | ||
own implementation, type-hint this in the arguments instead. | ||
|
||
As a developer, you might prefer not to extend the ``Controller``. To use the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This paragraph should be moved to the end of the next section ("Flash Messages") and can maybe be put in a .. sidebar::
or .. tip::
directive instead.
@@ -18,6 +18,9 @@ functionality. | |||
Functionality Shipped with the HttpKernel | |||
----------------------------------------- | |||
|
|||
.. versionadded:: 3.3 | |||
The ``SessionValueResolver`` was introduced in Symfony 3.3. | |||
|
|||
Symfony ships with four value resolvers in the HttpKernel component: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
four -> five
Thank you @iltar. |
Explains the functionality added in symfony/symfony#21164