Skip to content

[Security] Move the Security helper to SecurityBundle #16848

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

Merged
merged 1 commit into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controller/argument_value_resolver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ retrieved from the token storage::
namespace App\ArgumentResolver;

use App\Entity\User;
use Symfony\Bundle\SecurityBundle\Security\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
use Symfony\Component\Security\Core\Security;

class UserValueResolver implements ArgumentValueResolverInterface
{
Expand Down
4 changes: 2 additions & 2 deletions form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ The problem is now to get the current user and create a choice field that
contains only this user's friends. This can be done injecting the ``Security``
service into the form type so you can get the current user object::

use Symfony\Component\Security\Core\Security;
use Symfony\Bundle\SecurityBundle\Security\Security;
// ...

class FriendMessageFormType extends AbstractType
Expand All @@ -260,9 +260,9 @@ security helper to fill in the listener logic::
use App\Entity\User;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Bundle\SecurityBundle\Security\Security;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Security\Core\Security;
// ...

class FriendMessageFormType extends AbstractType
Expand Down
12 changes: 9 additions & 3 deletions security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1775,12 +1775,12 @@ Fetching the User from a Service
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you need to get the logged in user from a service, use the
:class:`Symfony\\Component\\Security\\Core\\Security` service::
:class:`Symfony\\Bundle\\SecurityBundle\\Security\\Security` service::

// src/Service/ExampleService.php
// ...

use Symfony\Component\Security\Core\Security;
use Symfony\Bundle\SecurityBundle\Security\Security;

class ExampleService
{
Expand All @@ -1802,6 +1802,12 @@ If you need to get the logged in user from a service, use the
}
}

.. versionadded:: 6.2

The :class:`Symfony\\Bundle\\SecurityBundle\\Security\\Security` class
was introduced in Symfony 6.2. In previous Symfony versions this class was
defined in ``Symfony\Component\Security\Core\Security``.

Fetch the User in a Template
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -2235,7 +2241,7 @@ want to include extra details only for users that have a ``ROLE_SALES_ADMIN`` ro

// ...
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
+ use Symfony\Component\Security\Core\Security;
+ use Symfony\Bundle\SecurityBundle\Security\Security;

class SalesReportManager
{
Expand Down
4 changes: 2 additions & 2 deletions security/impersonating_user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ the impersonator user::
// src/Service/SomeService.php
namespace App\Service;

use Symfony\Bundle\SecurityBundle\Security\Security;
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
use Symfony\Component\Security\Core\Security;
// ...

class SomeService
Expand Down Expand Up @@ -306,9 +306,9 @@ logic you want::
// src/Security/Voter/SwitchToCustomerVoter.php
namespace App\Security\Voter;

use Symfony\Bundle\SecurityBundle\Security\Security;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\User\UserInterface;

class SwitchToCustomerVoter extends Voter
Expand Down
2 changes: 1 addition & 1 deletion security/voters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ with ``ROLE_SUPER_ADMIN``::
// src/Security/PostVoter.php

// ...
use Symfony\Component\Security\Core\Security;
use Symfony\Bundle\SecurityBundle\Security\Security;

class PostVoter extends Voter
{
Expand Down
2 changes: 1 addition & 1 deletion session/proxy_examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ can intercept the session before it is written::
namespace App\Session;

use App\Entity\User;
use Symfony\Bundle\SecurityBundle\Security\Security;
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
use Symfony\Component\Security\Core\Security;

class ReadOnlySessionProxy extends SessionHandlerProxy
{
Expand Down