mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-27 10:03:49 +00:00
Remove usage of deprecated Role class
This commit is contained in:
@@ -19,7 +19,6 @@ use Chill\MainBundle\Security\ParentRoleHelper;
|
||||
use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
|
||||
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Traversable;
|
||||
use UnexpectedValueException;
|
||||
@@ -48,10 +47,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
{
|
||||
$results = [];
|
||||
|
||||
if ($role instanceof Role) {
|
||||
$role = $role->getRole();
|
||||
}
|
||||
|
||||
foreach ($centers as $center) {
|
||||
if ($this->userCanReachCenter($user, $center)) {
|
||||
$results[] = $center;
|
||||
@@ -94,10 +89,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
*/
|
||||
public function getReachableCenters(UserInterface $user, string $role, ?Scope $scope = null): array
|
||||
{
|
||||
if ($role instanceof Role) {
|
||||
$role = $role->getRole();
|
||||
}
|
||||
|
||||
if (!$user instanceof User) {
|
||||
return [];
|
||||
}
|
||||
@@ -135,7 +126,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
* @param Center|Center[] $center
|
||||
* @return Scope[]
|
||||
*/
|
||||
public function getReachableCircles(UserInterface $user, \Symfony\Component\Security\Core\Role\Role|string $role, \Chill\MainBundle\Entity\Center|array $center)
|
||||
public function getReachableCircles(UserInterface $user, string $role, \Chill\MainBundle\Entity\Center|array $center)
|
||||
{
|
||||
$scopes = [];
|
||||
|
||||
@@ -147,10 +138,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
return $scopes;
|
||||
}
|
||||
|
||||
if ($role instanceof Role) {
|
||||
$role = $role->getRole();
|
||||
}
|
||||
|
||||
foreach ($user->getGroupCenters() as $groupCenter) {
|
||||
if ($center->getId() === $groupCenter->getCenter()->getId()) {
|
||||
//iterate on permissionGroup
|
||||
@@ -219,11 +206,11 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
* the scope is taken into account.
|
||||
*
|
||||
* @param mixed $entity the entity may also implement HasScopeInterface
|
||||
* @param Role|string $attribute
|
||||
* @param string $attribute
|
||||
*
|
||||
* @return bool true if the user has access
|
||||
*/
|
||||
public function userHasAccess(User $user, mixed $entity, \Symfony\Component\Security\Core\Role\Role|string $attribute)
|
||||
public function userHasAccess(User $user, mixed $entity, string $attribute)
|
||||
{
|
||||
$centers = $this->centerResolverManager->resolveCenters($entity);
|
||||
|
||||
|
Reference in New Issue
Block a user