\Piko\User

Application User base class.

Properties summary

Name Description
public $authTimeout The number of seconds in which the user will be lo…
public $checkAccess Callback to check user permission The callback sig…
public $identityClass The class name of the identity object.
protected $access Internal cache of access permissions.
protected $identity The identity instance.

Inherited Properties

Name Description
protected $eventDispatcher  
protected $listenerProvider  

Methods summary

Name Description
public __construct Constructor
public can Check if the user can do an action.
public getId Get user identifier.
public getIdentity Get user identity
public isGuest Returns a value indicating whether the user is a g…
public login Start the session and set user identity.
public logout Destroy the session and remove user identity.
public setIdentity Set user identity.
protected startSession  

Inherited Methods

Name Description
public on Registers an event listener.
public trigger Trigger an event that may be listen by event liste…

Properties

public $authTimeout : int

The number of seconds in which the user will be logged out automatically if he remains inactive.

public $checkAccess : callable

Callback to check user permission The callback signature must be : function(int $userId, string $permission): bool

public $identityClass : string

The class name of the identity object.

protected $access : bool[]

Internal cache of access permissions.

protected $identity : \Piko\User\IdentityInterface|null

The identity instance.


Methods

public __construct(): mixed

public  __construct(array<string,mixed>  $config = []): mixed

Parameters

$config (default: []):

Return:

mixed


public can(): bool

public  can(string  $permission): bool

Check if the user can do an action.

Parameters

$permission : The permission name.

Return:

bool


public getId(): string|int|null

public  getId(): string|int|null

Get user identifier.

Return:

string|int|null


public getIdentity(): \Piko\User\IdentityInterface|null

public  getIdentity(): \Piko\User\IdentityInterface|null

Get user identity

Return:

\Piko\User\IdentityInterface|null The user identity or null if no identity is found.


public isGuest(): bool

public  isGuest(): bool

Returns a value indicating whether the user is a guest (not authenticated).

Return:

bool whether the current user is a guest.


public login(): void

public  login(\Piko\User\IdentityInterface  $identity): void

Start the session and set user identity.

Parameters

$identity : The user identity.


public logout(): void

public  logout(): void

Destroy the session and remove user identity.


public setIdentity(): void

public  setIdentity(\Piko\User\IdentityInterface  $identity): void

Set user identity.

Parameters

$identity : The user identity.

throws \RuntimeExceptionIf identiy doesn’t implement IdentityInterface.


protected startSession(): void

protected  startSession(): void