Skip to content

Use the new Security helper in some code examples #9847

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

Closed
wants to merge 3 commits into from

Conversation

javiereguiluz
Copy link
Member

@javiereguiluz javiereguiluz commented May 28, 2018

This fixes #8437 replacing use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; by use Symfony\Component\Security\Core\Security; when possible.

Also, replace use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; by use Symfony\Component\Security\Core\Security; when possible.

$impersonatorUser = $role->getSource()->getUser();
break;
if ($this->security->isGranted('ROLE_PREVIOUS_ADMIN')) {
foreach ($this->security->getToken()->getRoles() as $role) {
Copy link
Member

Choose a reason for hiding this comment

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

like $this->security->getUser() shouldn't it hide ->getToken() to access to ->getRoles() directly?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm sorry but I don't understand this comment.

Copy link
Member

@yceruto yceruto May 31, 2018

Choose a reason for hiding this comment

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

I expected like $this->security->getUser() a shortcut like $this->security->getRoles() instead of $this->security->getToken()->getRoles() but I've seen that this has not been added to this helper. Nevermind, anyway this only documents what is implemented.

javiereguiluz added a commit that referenced this pull request Jun 1, 2018
…eguiluz)

This PR was squashed before being merged into the 3.4 branch (closes #9847).

Discussion
----------

Use the new Security helper in some code examples

This fixes #8437 replacing `use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;` by `use Symfony\Component\Security\Core\Security;` when possible.

Also, replace `use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;` by `use Symfony\Component\Security\Core\Security;` when possible.

Commits
-------

df21fd8 Use the new Security helper in some code examples
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.

3 participants