Skip to content

Commit 7e01616

Browse files
committed
feature #13323 [Security] removed usage of the deprecated SecurityContextInterface (fabpot)
This PR was merged into the 2.7 branch. Discussion ---------- [Security] removed usage of the deprecated SecurityContextInterface | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a This PR removed internal usage of SecurityContextInterface in favor of the new alternatives, it also fixes removes as many deprecation notices as possible for the Security component. Commits ------- ba71b68 added type-hint 91d01d8 [Security] removed usage of the deprecated SecurityContextInterface
2 parents d85409c + 1760ea9 commit 7e01616

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider;
1313

14-
trigger_error('The '.__NAMESPACE__.'\CsrfTokenManagerAdapter is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
15-
1614
use Symfony\Component\Security\Csrf\CsrfToken;
1715
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
1816

@@ -36,8 +34,12 @@ public function __construct(CsrfTokenManagerInterface $tokenManager)
3634
$this->tokenManager = $tokenManager;
3735
}
3836

39-
public function getTokenManager()
37+
public function getTokenManager($triggerDeprecationError = true)
4038
{
39+
if ($triggerDeprecationError) {
40+
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
41+
}
42+
4143
return $this->tokenManager;
4244
}
4345

@@ -46,6 +48,8 @@ public function getTokenManager()
4648
*/
4749
public function generateCsrfToken($intention)
4850
{
51+
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
52+
4953
return $this->tokenManager->getToken($intention)->getValue();
5054
}
5155

@@ -54,6 +58,8 @@ public function generateCsrfToken($intention)
5458
*/
5559
public function isCsrfTokenValid($intention, $token)
5660
{
61+
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in version 3.0. Use the Symfony\Component\Security\Csrf\CsrfTokenManager class instead.', E_USER_DEPRECATED);
62+
5763
return $this->tokenManager->isTokenValid(new CsrfToken($intention, $token));
5864
}
5965
}

Extension/Csrf/Type/FormTypeCsrfExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
133133
}
134134

135135
return $options['csrf_provider'] instanceof CsrfTokenManagerAdapter
136-
? $options['csrf_provider']->getTokenManager()
136+
? $options['csrf_provider']->getTokenManager(false)
137137
: new CsrfProviderAdapter($options['csrf_provider']);
138138
};
139139

0 commit comments

Comments
 (0)