mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
refactor centerType
This commit is contained in:
@@ -41,9 +41,8 @@ use Chill\MainBundle\Entity\RoleScope;
|
||||
*
|
||||
* Provides methods for user and entities information.
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class AuthorizationHelper
|
||||
class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
{
|
||||
protected RoleHierarchyInterface $roleHierarchy;
|
||||
|
||||
@@ -203,9 +202,9 @@ class AuthorizationHelper
|
||||
* @param User $user
|
||||
* @param string|Role $role
|
||||
* @param null|Scope $scope
|
||||
* @return Center[]
|
||||
* @return Center[]|array
|
||||
*/
|
||||
public function getReachableCenters(User $user, $role, Scope $scope = null)
|
||||
public function getReachableCenters(User $user, string $role, ?Scope $scope = null): array
|
||||
{
|
||||
if ($role instanceof Role) {
|
||||
$role = $role->getRole();
|
||||
@@ -267,9 +266,9 @@ class AuthorizationHelper
|
||||
* @param User $user
|
||||
* @param string role
|
||||
* @param Center|Center[] $center
|
||||
* @return Scope[]
|
||||
* @return Scope[]|array
|
||||
*/
|
||||
public function getReachableScopes(User $user, $role, $center)
|
||||
public function getReachableScopes(User $user, string $role, $center): array
|
||||
{
|
||||
if ($role instanceof Role) {
|
||||
$role = $role->getRole();
|
||||
|
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
interface AuthorizationHelperInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Get reachable Centers for the given user, role,
|
||||
* and optionnaly Scope
|
||||
*
|
||||
* @param User $user
|
||||
* @param string|Role $role
|
||||
* @param null|Scope $scope
|
||||
* @return Center[]
|
||||
*/
|
||||
public function getReachableCenters(User $user, string $role, ?Scope $scope = null): array;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $role
|
||||
* @param Center|Center[]|array $center
|
||||
* @return array
|
||||
*/
|
||||
public function getReachableScopes(User $user, string $role, $center): array;
|
||||
|
||||
}
|
Reference in New Issue
Block a user