UserFrosting API

AuthorizationManager

AuthorizationManager class.

Manages a collection of access condition callbacks, and uses them to perform access control checks on user objects.

Tags
author

Alex Weissman (https://alexanderweissman.com)

Table of Contents

$ci ContainerInterface
$callbacks
__construct() Create a new AuthorizationManager object. mixed
addCallback() Register an authorization callback, which can then be used in permission conditions. mixed
getCallbacks() Get all authorization callbacks. callable[]
checkAccess() Checks whether or not a user has access on a particular permission slug. bool
getPermissionsArrayDebugInfo() Remove extraneous information from the permission to reduce verbosity. array

Properties

Methods

__construct()

Create a new AuthorizationManager object.

public __construct( $ci : ContainerInterface [, $callbacks : array = [] ] ) : mixed
Parameters
$ci : ContainerInterface

The global container object, which holds all your services.

$callbacks : array = []
Return values
mixed

addCallback()

Register an authorization callback, which can then be used in permission conditions.

public addCallback( $name : string , $callback : callable ) : mixed

To add additional callbacks, simply extend the authorizer service in your Sprinkle's service provider.

Parameters
$name : string
$callback : callable
Return values
mixed

getCallbacks()

Get all authorization callbacks.

public getCallbacks( ) : callable[]
Return values
callable[]

checkAccess()

Checks whether or not a user has access on a particular permission slug.

public checkAccess( $user : UserInterface|null , $slug : string [, $params : array = [] ] ) : bool

Determine if this user has access to the given $slug under the given $params.

Parameters
$user : UserInterface|null
$slug : string

The permission slug to check for access.

$params : array = []

An array of field names => values, specifying any additional data to provide the authorization module when determining whether or not this user has access.

Return values
bool

True if the user has access, false otherwise.

getPermissionsArrayDebugInfo()

Remove extraneous information from the permission to reduce verbosity.

protected getPermissionsArrayDebugInfo( $permissions : array ) : array
Parameters
$permissions : array
Return values
array

Search results