-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBridge] Added access to token from twig AppVariable #19991
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
@@ -57,13 +72,7 @@ public function setDebug($debug) | |||
*/ | |||
public function getUser() | |||
{ | |||
if (null !== $this->tokenStorage) { |
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.
not sure this change is needed, and it forces the error message to be less specific
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.
It's moved to the getToken()
method.
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.
Ah, I see what you mean now. Indeed the message will not be specific to the user anymore (will be about token). I'd indeed keep the check and throw an exception like before.
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.
fair enough
0604d54
to
a56a108
Compare
a56a108
to
efd3e2d
Compare
Comments addressed. |
Thank you @HeahDude. |
…le (HeahDude) This PR was merged into the 3.2-dev branch. Discussion ---------- [TwigBridge] Added access to token from twig AppVariable | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | TODO In Symfony 2.x we could access the token from `app.security` but now we can only get the user even if it comes from the token storage. This makes mandatory to create a custom twig extension to access it and thus harder to update to symfony 3.x when you need this simple getter in a template where custom tokens are involved (e.g using a ConnectToken from SensioLabs Connect API). I hope this little feature will be part of 3.2 :) Commits ------- efd3e2d Added access to token from twig AppVariable
…eahDude) This PR was merged into the 3.3-dev branch. Discussion ---------- [FrameworkBundle] Added GlobalVariables::getToken() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony-docs#7191 comments | License | MIT | Doc PR | symfony/symfony-docs#7191 I propose this feature as bug fix in 3.2, since I don't use the PHP templating I forgot to add the method in the `FrameworkBundle`, to keep it align with the `TwigBridge` in #19991. Is this acceptable or should it go in master? Commits ------- 099b848 Added GlobalVariables::getToken()
…eahDude) This PR was merged into the 3.3-dev branch. Discussion ---------- [FrameworkBundle] Added GlobalVariables::getToken() | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony/symfony-docs#7191 comments | License | MIT | Doc PR | symfony/symfony-docs#7191 I propose this feature as bug fix in 3.2, since I don't use the PHP templating I forgot to add the method in the `FrameworkBundle`, to keep it align with the `TwigBridge` in symfony/symfony#19991. Is this acceptable or should it go in master? Commits ------- 099b848 Added GlobalVariables::getToken()
In Symfony 2.x we could access the token from
app.security
but now we can only get the user even if it comes from the token storage.This makes mandatory to create a custom twig extension to access it and thus harder to update to symfony 3.x when you need this simple getter in a template where custom tokens are involved (e.g using a ConnectToken from SensioLabs Connect API).
I hope this little feature will be part of 3.2 :)