From c7369d57a436c8984ec945e65f563e2310f59f6d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 6 Jun 2022 10:06:13 +0200 Subject: [PATCH] [Security][SecurityBundle] Move the Security helper to SecurityBundle --- controller/argument_value_resolver.rst | 2 +- form/dynamic_form_modification.rst | 4 ++-- security.rst | 12 +++++++++--- security/impersonating_user.rst | 4 ++-- security/voters.rst | 2 +- session/proxy_examples.rst | 2 +- 6 files changed, 16 insertions(+), 10 deletions(-) diff --git a/controller/argument_value_resolver.rst b/controller/argument_value_resolver.rst index 5ffa9ada86b..4b6b14ad7b2 100644 --- a/controller/argument_value_resolver.rst +++ b/controller/argument_value_resolver.rst @@ -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 { diff --git a/form/dynamic_form_modification.rst b/form/dynamic_form_modification.rst index 0af5266e9a4..fcf995b50e9 100644 --- a/form/dynamic_form_modification.rst +++ b/form/dynamic_form_modification.rst @@ -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 @@ -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 diff --git a/security.rst b/security.rst index dac009b6c66..22aea950fe2 100644 --- a/security.rst +++ b/security.rst @@ -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 { @@ -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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -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 { diff --git a/security/impersonating_user.rst b/security/impersonating_user.rst index df07bbe4af8..3219802edb7 100644 --- a/security/impersonating_user.rst +++ b/security/impersonating_user.rst @@ -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 @@ -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 diff --git a/security/voters.rst b/security/voters.rst index 600fee884dd..7541d4149a1 100644 --- a/security/voters.rst +++ b/security/voters.rst @@ -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 { diff --git a/session/proxy_examples.rst b/session/proxy_examples.rst index 67d46adb27b..a9114216ea8 100644 --- a/session/proxy_examples.rst +++ b/session/proxy_examples.rst @@ -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 {