Skip to content
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

[TwigBridge] Added access to token from twig AppVariable #19991

Merged
merged 1 commit into from
Oct 5, 2016

Conversation

HeahDude
Copy link
Contributor

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 :)

@@ -57,13 +72,7 @@ public function setDebug($debug)
*/
public function getUser()
{
if (null !== $this->tokenStorage) {
Copy link
Member

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough

@HeahDude
Copy link
Contributor Author

Comments addressed.

@fabpot
Copy link
Member

fabpot commented Oct 5, 2016

Thank you @HeahDude.

@fabpot fabpot merged commit efd3e2d into symfony:master Oct 5, 2016
fabpot added a commit that referenced this pull request Oct 5, 2016
…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
@HeahDude HeahDude deleted the feature/twig-app_token branch October 5, 2016 06:30
@fabpot fabpot mentioned this pull request Oct 27, 2016
fabpot added a commit that referenced this pull request Dec 13, 2016
…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()
symfony-splitter pushed a commit to symfony/framework-bundle that referenced this pull request Dec 13, 2016
…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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants