PHP Class Silber\Bouncer\Clipboard

Inheritance: use trait Illuminate\Auth\Access\HandlesAuthorization
Show file Open project: JosephSilber/bouncer Class Usage Examples

Public Methods

Method Description
check ( Model $authority, string $ability, Model | string | null $model = null ) : boolean Determine if the given authority has the given ability.
checkRole ( Model $authority, array | string $roles, string $boolean = 'or' ) : boolean Check if an authority has the given roles.
getAbilities ( Model $authority, boolean $allowed = true ) : Illuminate\Database\Eloquent\Collection Get a list of the authority's abilities.
getForbiddenAbilities ( Model $authority ) : Illuminate\Database\Eloquent\Collection Get a list of the authority's forbidden abilities.
getRoles ( Model $authority ) : Collection Get the given authority's roles.
registerAt ( Illuminate\Contracts\Auth\Access\Gate $gate ) : void Register the clipboard at the given gate.

Protected Methods

Method Description
checkGetId ( Model $authority, string $ability, Model | string | null $model = null ) : integer | boolean | null Determine if the given authority has the given ability, and return the ability ID.
compileAbilityIdentifiers ( string $ability, Model | string | null $model ) : Collection Compile a list of ability identifiers that match the provided parameters.
compileModelAbilityIdentifiers ( string $ability, Model | string $model ) : array Compile a list of ability identifiers that match the given model.
findMatchingAbility ( Collection $abilities, Collection $applicable, Model $model, Model $authority ) : integer | null Determine if any of the abilities can be matched against the provided applicable ones.
getMatchedAbilityId ( Collection $abilityMap, Collection $applicable ) : integer | null Get the ID of the ability that matches one of the applicable abilities.
parseGateArguments ( mixed $arguments, mixed $additional ) : array Parse the arguments we got from the gate.

Method Details

check() public method

Determine if the given authority has the given ability.
public check ( Model $authority, string $ability, Model | string | null $model = null ) : boolean
$authority Illuminate\Database\Eloquent\Model
$ability string
$model Illuminate\Database\Eloquent\Model | string | null
return boolean

checkGetId() protected method

Determine if the given authority has the given ability, and return the ability ID.
protected checkGetId ( Model $authority, string $ability, Model | string | null $model = null ) : integer | boolean | null
$authority Illuminate\Database\Eloquent\Model
$ability string
$model Illuminate\Database\Eloquent\Model | string | null
return integer | boolean | null

checkRole() public method

Check if an authority has the given roles.
public checkRole ( Model $authority, array | string $roles, string $boolean = 'or' ) : boolean
$authority Illuminate\Database\Eloquent\Model
$roles array | string
$boolean string
return boolean

compileAbilityIdentifiers() protected method

Compile a list of ability identifiers that match the provided parameters.
protected compileAbilityIdentifiers ( string $ability, Model | string | null $model ) : Collection
$ability string
$model Illuminate\Database\Eloquent\Model | string | null
return Illuminate\Support\Collection

compileModelAbilityIdentifiers() protected method

Compile a list of ability identifiers that match the given model.
protected compileModelAbilityIdentifiers ( string $ability, Model | string $model ) : array
$ability string
$model Illuminate\Database\Eloquent\Model | string
return array

findMatchingAbility() protected method

Determine if any of the abilities can be matched against the provided applicable ones.
protected findMatchingAbility ( Collection $abilities, Collection $applicable, Model $model, Model $authority ) : integer | null
$abilities Illuminate\Support\Collection
$applicable Illuminate\Support\Collection
$model Illuminate\Database\Eloquent\Model
$authority Illuminate\Database\Eloquent\Model
return integer | null

getAbilities() public method

Get a list of the authority's abilities.
public getAbilities ( Model $authority, boolean $allowed = true ) : Illuminate\Database\Eloquent\Collection
$authority Illuminate\Database\Eloquent\Model
$allowed boolean
return Illuminate\Database\Eloquent\Collection

getForbiddenAbilities() public method

Get a list of the authority's forbidden abilities.
public getForbiddenAbilities ( Model $authority ) : Illuminate\Database\Eloquent\Collection
$authority Illuminate\Database\Eloquent\Model
return Illuminate\Database\Eloquent\Collection

getMatchedAbilityId() protected method

Get the ID of the ability that matches one of the applicable abilities.
protected getMatchedAbilityId ( Collection $abilityMap, Collection $applicable ) : integer | null
$abilityMap Illuminate\Support\Collection
$applicable Illuminate\Support\Collection
return integer | null

getRoles() public method

Get the given authority's roles.
public getRoles ( Model $authority ) : Collection
$authority Illuminate\Database\Eloquent\Model
return Illuminate\Support\Collection

parseGateArguments() protected method

Parse the arguments we got from the gate.
protected parseGateArguments ( mixed $arguments, mixed $additional ) : array
$arguments mixed
$additional mixed
return array

registerAt() public method

Register the clipboard at the given gate.
public registerAt ( Illuminate\Contracts\Auth\Access\Gate $gate ) : void
$gate Illuminate\Contracts\Auth\Access\Gate
return void