PermissionRegistrar
in package
implements
PermissionRegistrar
Table of Contents
Interfaces
- PermissionRegistrar
- Interface PermissionRegistrar.
Properties
- $cacheExpirationTime : DateInterval|int
- $cacheKey : string
- $pivotPermission : string
- $pivotRole : string
- $teams : bool
- $teamsKey : string
- $cache : Repository
- $cacheManager : CacheManager
- $permisionWildcards : array<string, mixed>
- $permissionClass : string
- $permissions : Collection
- $permissionValues : array<string, mixed>
- $permissionViaRole : array<int, array<string, bool>>
- [ 1 => [ 'feed.view' => true, 'feed.create' => true, ] ].
- $roleClass : string
- $teamId : int|string
- $alias : array<string|int, mixed>
- $cachedRoles : array<string|int, mixed>
- $except : array<string|int, mixed>
- $userRoleMap : array<string|int, mixed>
Methods
- __construct() : mixed
- PermissionRegistrar constructor.
- clearClassPermissions() : mixed
- Clear class permissions.
- forgetCachedPermissions() : mixed
- Flush the cache.
- getCacheRepository() : Repository
- getCacheStore() : Store
- getPermission() : Permission|null
- Get the permission based on name.
- getPermissionClass() : Permission
- Get an instance of the permission class.
- getPermissions() : Collection
- Get the permissions based on the passed params.
- getPermissionsTeamId() : int|string
- getPermissionViaRole() : bool|null
- getRoleClass() : Role
- Get an instance of the role class.
- initializeCache() : mixed
- loadPermissionsViaRole() : mixed
- registerPermissions() : bool
- Register the permission check method on the gate.
- setPermissionClass() : mixed
- setPermissionsTeamId() : mixed
- Set the team id for teams/groups support, this id is used when querying permissions/roles.
- setPermissionViaRole() : void
- setRoleClass() : mixed
- getCacheStoreFromConfig() : Repository
- getPermissionsWithRoles() : Collection
- readPermisionFromDb() : mixed
- aliasedArray() : array<string|int, mixed>
- Changes array keys with alias.
- aliasModelFields() : void
- Array for cache alias.
- getHydratedPermissionCollection() : mixed
- getHydratedRoleCollection() : mixed
- getSerializedPermissionsForCache() : mixed
- getSerializedRoleRelation() : mixed
- hydrateRolesCache() : mixed
- loadPermissions() : mixed
- Load permissions from cache This get cache and turns array into \Illuminate\Database\Eloquent\Collection.
Properties
$cacheExpirationTime
public
static DateInterval|int
$cacheExpirationTime
$cacheKey
public
static string
$cacheKey
$pivotPermission
public
static string
$pivotPermission
$pivotRole
public
static string
$pivotRole
$teams
public
static bool
$teams
$teamsKey
public
static string
$teamsKey
$cache
protected
Repository
$cache
$cacheManager
protected
CacheManager
$cacheManager
$permisionWildcards
protected
array<string, mixed>
$permisionWildcards
$permissionClass
protected
string
$permissionClass
$permissions
protected
Collection
$permissions
$permissionValues
protected
array<string, mixed>
$permissionValues
$permissionViaRole
[ 1 => [ 'feed.view' => true, 'feed.create' => true, ] ].
protected
array<int, array<string, bool>>
$permissionViaRole
= []
$roleClass
protected
string
$roleClass
$teamId
protected
int|string
$teamId
= null
$alias
private
array<string|int, mixed>
$alias
= []
$cachedRoles
private
array<string|int, mixed>
$cachedRoles
= []
$except
private
array<string|int, mixed>
$except
= []
$userRoleMap
private
array<string|int, mixed>
$userRoleMap
= []
Methods
__construct()
PermissionRegistrar constructor.
public
__construct(CacheManager $cacheManager) : mixed
Parameters
- $cacheManager : CacheManager
clearClassPermissions()
Clear class permissions.
public
clearClassPermissions() : mixed
This is only intended to be called by the PermissionServiceProvider on boot, so that long-running instances like Swoole don't keep old data in memory.
forgetCachedPermissions()
Flush the cache.
public
forgetCachedPermissions() : mixed
getCacheRepository()
public
getCacheRepository() : Repository
Return values
RepositorygetCacheStore()
public
getCacheStore() : Store
Return values
StoregetPermission()
Get the permission based on name.
public
getPermission(string $name) : Permission|null
Parameters
- $name : string
Return values
Permission|nullgetPermissionClass()
Get an instance of the permission class.
public
getPermissionClass() : Permission
Return values
PermissiongetPermissions()
Get the permissions based on the passed params.
public
getPermissions([array<string|int, mixed> $params = [] ][, bool $onlyOne = false ]) : Collection
Parameters
- $params : array<string|int, mixed> = []
- $onlyOne : bool = false
Return values
CollectiongetPermissionsTeamId()
public
getPermissionsTeamId() : int|string
Return values
int|stringgetPermissionViaRole()
public
getPermissionViaRole(User $user, string $permission) : bool|null
Parameters
- $user : User
- $permission : string
Return values
bool|nullgetRoleClass()
Get an instance of the role class.
public
getRoleClass() : Role
Return values
RoleinitializeCache()
public
initializeCache() : mixed
loadPermissionsViaRole()
public
loadPermissionsViaRole() : mixed
registerPermissions()
Register the permission check method on the gate.
public
registerPermissions() : bool
We resolve the Gate fresh here, for benefit of long-running instances.
Return values
boolsetPermissionClass()
public
setPermissionClass(mixed $permissionClass) : mixed
Parameters
- $permissionClass : mixed
setPermissionsTeamId()
Set the team id for teams/groups support, this id is used when querying permissions/roles.
public
setPermissionsTeamId(int|string|Model $id) : mixed
Parameters
- $id : int|string|Model
setPermissionViaRole()
public
setPermissionViaRole(User $user, string $permission, bool $value) : void
Parameters
- $user : User
- $permission : string
- $value : bool
setRoleClass()
public
setRoleClass(mixed $roleClass) : mixed
Parameters
- $roleClass : mixed
getCacheStoreFromConfig()
protected
getCacheStoreFromConfig() : Repository
Return values
RepositorygetPermissionsWithRoles()
protected
getPermissionsWithRoles() : Collection
Return values
CollectionreadPermisionFromDb()
protected
readPermisionFromDb() : mixed
aliasedArray()
Changes array keys with alias.
private
aliasedArray(mixed $model) : array<string|int, mixed>
Parameters
- $model : mixed
Return values
array<string|int, mixed>aliasModelFields()
Array for cache alias.
private
aliasModelFields([mixed $newKeys = [] ]) : void
Parameters
- $newKeys : mixed = []
getHydratedPermissionCollection()
private
getHydratedPermissionCollection() : mixed
getHydratedRoleCollection()
private
getHydratedRoleCollection(array<string|int, mixed> $roles) : mixed
Parameters
- $roles : array<string|int, mixed>
getSerializedPermissionsForCache()
private
getSerializedPermissionsForCache() : mixed
getSerializedRoleRelation()
private
getSerializedRoleRelation(mixed $permission) : mixed
Parameters
- $permission : mixed
hydrateRolesCache()
private
hydrateRolesCache() : mixed
loadPermissions()
Load permissions from cache This get cache and turns array into \Illuminate\Database\Eloquent\Collection.
private
loadPermissions() : mixed