You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of deprecating the interface it is sufficient to deprecate its
getReachableRoles() method and add a new getReachableRoleNames() method
in Symfony 5.
@@ -43,6 +42,10 @@ public function __construct(ExpressionLanguage $expressionLanguage, Authenticati
43
42
@trigger_error(sprintf('Passing a RoleHierarchyInterface to "%s()" is deprecated since Symfony 4.2. Pass an AuthorizationCheckerInterface instead.', __METHOD__), E_USER_DEPRECATED);
44
43
$roleHierarchy = $authChecker;
45
44
$authChecker = null;
45
+
46
+
if (!method_exists($roleHierarchy, 'getReachableRoleNames')) {
47
+
@trigger_error(sprintf('Not implementing the getReachableRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($this->roleHierarchy), RoleHierarchyInterface::class), E_USER_DEPRECATED);
48
+
}
46
49
} elseif (null === $authChecker) {
47
50
@trigger_error(sprintf('Argument 3 passed to "%s()" should be an instance of AuthorizationCheckerInterface, not passing it is deprecated since Symfony 4.2.', __METHOD__), E_USER_DEPRECATED);
if ($this->roleHierarchyinstanceof RoleHierarchy) {
96
-
if (method_exists($token, 'getRoleNames')) {
97
-
$rolesFromToken = $token->getRoleNames();
98
-
} else {
99
-
@trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing a role hierarchy to "%s" that is not an instance of "%s" is deprecated since Symfony 4.3 and support for it will be dropped in Symfony 5.0 ("%s" given).', __CLASS__, RoleHierarchy::class, \get_class($roleHierarchy)), E_USER_DEPRECATED);
31
+
if (!method_exists($roleHierarchy, 'getReachableRoleNames')) {
32
+
@trigger_error(sprintf('Not implementing the getReachableRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($roleHierarchy), RoleHierarchyInterface::class), E_USER_DEPRECATED);
32
33
}
33
34
34
35
$this->roleHierarchy = $roleHierarchy;
@@ -41,13 +42,13 @@ public function __construct(RoleHierarchyInterface $roleHierarchy, string $prefi
if ($this->roleHierarchyinstanceof RoleHierarchy) {
45
+
if (method_exists($this->roleHierarchy, 'getReachableRoleNames')) {
45
46
if (method_exists($token, 'getRoleNames')) {
46
47
$roles = $token->getRoleNames();
47
48
} else {
48
49
@trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED);
Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Role/RoleHierarchy.php
+4-11
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,9 @@ public function __construct(array $hierarchy)
36
36
*/
37
37
publicfunctiongetReachableRoles(array$roles)
38
38
{
39
-
@trigger_error(sprintf('The %s() method is deprecated since Symfony 4.3 and will be removed in 5.0. Use roles as strings and the getReachableRoleNames() method instead.', __METHOD__), E_USER_DEPRECATED);
39
+
if (0 === \func_num_args() || func_get_arg(0)) {
40
+
@trigger_error(sprintf('The %s() method is deprecated since Symfony 4.3 and will be removed in 5.0. Use roles as strings and the getReachableRoleNames() method instead.', __METHOD__), E_USER_DEPRECATED);
41
+
}
40
42
41
43
$reachableRoles = $roles;
42
44
foreach ($rolesas$role) {
@@ -59,16 +61,7 @@ public function getReachableRoles(array $roles)
if (null !== $roleHierarchy && !method_exists($roleHierarchy, 'getReachableRoleNames')) {
41
+
@trigger_error(sprintf('Not implementing the getReachableRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($roleHierarchy), RoleHierarchyInterface::class), E_USER_DEPRECATED);
42
+
}
43
+
40
44
$this->configuration = $configuration;
41
45
$this->expressionLanguage = $expressionLanguage;
42
46
$this->tokenStorage = $tokenStorage;
@@ -83,22 +87,29 @@ private function getVariables(GuardEvent $event): array
@trigger_error(sprintf('Not implementing the getRoleNames() method in %s which implements %s is deprecated since Symfony 4.3.', \get_class($token), TokenInterface::class), E_USER_DEPRECATED);
0 commit comments