KMP PHP API Reference

ImpersonationService
in package

Manages impersonation session metadata for super user actions.

Stores original administrator details alongside the impersonated identity so we can revert safely and display contextual warnings. All state is persisted in the session under a single namespace.

Table of Contents

Constants

SESSION_KEY  = 'Impersonation'

Methods

getState()  : array<string, mixed>|null
Retrieve the current impersonation state.
isActive()  : bool
Determine whether impersonation is active for the given session.
start()  : array<string, mixed>
Persist impersonation metadata for the active session.
stop()  : array<string, mixed>|null
Clear impersonation metadata from the session and return the snapshot.
clearIdentityCaches()  : void
Reset caches that depend on the current identity to prevent leakage between users.
logSessionEvent()  : void
Persist start/stop events for impersonation sessions.

Constants

SESSION_KEY

public string SESSION_KEY = 'Impersonation'

Session namespace for impersonation state

Methods

getState()

Retrieve the current impersonation state.

public getState(Session $session) : array<string, mixed>|null
Parameters
$session : Session

Active request session

Return values
array<string, mixed>|null

isActive()

Determine whether impersonation is active for the given session.

public isActive(Session $session) : bool
Parameters
$session : Session

Active request session

Return values
bool

start()

Persist impersonation metadata for the active session.

public start(Session $session, Member $impersonator, Member $target) : array<string, mixed>
Parameters
$session : Session

Active request session

$impersonator : Member

Super user initiating impersonation

$target : Member

Member being impersonated

Return values
array<string, mixed>

Immutable snapshot of impersonation state

stop()

Clear impersonation metadata from the session and return the snapshot.

public stop(Session $session) : array<string, mixed>|null
Parameters
$session : Session

Active request session

Return values
array<string, mixed>|null

Snapshot of impersonation state or null when inactive

clearIdentityCaches()

Reset caches that depend on the current identity to prevent leakage between users.

protected clearIdentityCaches(Session $session, int ...$memberIds) : void
Parameters
$session : Session
$memberIds : int

logSessionEvent()

Persist start/stop events for impersonation sessions.

protected logSessionEvent(string $event, Member $impersonator, Member $target) : void
Parameters
$event : string
$impersonator : Member
$target : Member

        
On this page

Search results