PHP Class Silber\Bouncer\CachedClipboard

Inheritance: extends Clipboard
Show file Open project: JosephSilber/bouncer Class Usage Examples

Protected Properties

Property Type Description
$cache Illuminate\Contracts\Cache\Store The cache store.
$tag string The tag used for caching.

Public Methods

Method Description
__construct ( Illuminate\Contracts\Cache\Store $cache ) Constructor.
getAbilities ( Model $authority, boolean $allowed = true ) : Illuminate\Database\Eloquent\Collection Get the given authority's abilities.
getCache ( ) : Illuminate\Contracts\Cache\Store Get the cache instance.
getFreshAbilities ( Model $authority, boolean $allowed ) : Illuminate\Database\Eloquent\Collection Get a fresh copy of the given authority's abilities.
getRoles ( Model $authority ) : Collection Get the given authority's roles.
refresh ( null | Model $authority = null ) Clear the cache.
refreshFor ( Model $authority ) Clear the cache for the given authority.
setCache ( Illuminate\Contracts\Cache\Store $cache ) Set the cache instance.

Protected Methods

Method Description
deserializeAbilities ( array $abilities ) : Illuminate\Database\Eloquent\Collection Deserialize an array of abilities into a collection of models.
getCacheKey ( Model $model, string $type, boolean $allowed = true ) : string Get the cache key for the given model's cache type.
refreshAllIteratively ( ) : void Refresh the cache for all roles and users, iteratively.
sear ( string $key, callable $callback ) : mixed Get an item from the cache, or store the default value forever.
serializeAbilities ( Illuminate\Database\Eloquent\Collection $abilities ) : array Serialize a collection of ability models into a plain array.

Method Details

__construct() public method

Constructor.
public __construct ( Illuminate\Contracts\Cache\Store $cache )
$cache Illuminate\Contracts\Cache\Store

deserializeAbilities() protected method

Deserialize an array of abilities into a collection of models.
protected deserializeAbilities ( array $abilities ) : Illuminate\Database\Eloquent\Collection
$abilities array
return Illuminate\Database\Eloquent\Collection

getAbilities() public method

Get the given 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

getCache() public method

Get the cache instance.
public getCache ( ) : Illuminate\Contracts\Cache\Store
return Illuminate\Contracts\Cache\Store

getCacheKey() protected method

Get the cache key for the given model's cache type.
protected getCacheKey ( Model $model, string $type, boolean $allowed = true ) : string
$model Illuminate\Database\Eloquent\Model
$type string
$allowed boolean
return string

getFreshAbilities() public method

Get a fresh copy of the given authority's abilities.
public getFreshAbilities ( Model $authority, boolean $allowed ) : Illuminate\Database\Eloquent\Collection
$authority Illuminate\Database\Eloquent\Model
$allowed boolean
return Illuminate\Database\Eloquent\Collection

getRoles() public method

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

refresh() public method

Clear the cache.
public refresh ( null | Model $authority = null )
$authority null | Illuminate\Database\Eloquent\Model

refreshAllIteratively() protected method

Refresh the cache for all roles and users, iteratively.
protected refreshAllIteratively ( ) : void
return void

refreshFor() public method

Clear the cache for the given authority.
public refreshFor ( Model $authority )
$authority Illuminate\Database\Eloquent\Model

sear() protected method

Get an item from the cache, or store the default value forever.
protected sear ( string $key, callable $callback ) : mixed
$key string
$callback callable
return mixed

serializeAbilities() protected method

Serialize a collection of ability models into a plain array.
protected serializeAbilities ( Illuminate\Database\Eloquent\Collection $abilities ) : array
$abilities Illuminate\Database\Eloquent\Collection
return array

setCache() public method

Set the cache instance.
public setCache ( Illuminate\Contracts\Cache\Store $cache )
$cache Illuminate\Contracts\Cache\Store

Property Details

$cache protected property

The cache store.
protected Store,Illuminate\Contracts\Cache $cache
return Illuminate\Contracts\Cache\Store

$tag protected property

The tag used for caching.
protected string $tag
return string