Documentation

SessionStateManager

Adapter for PHP session state management.

Abstracts $_SESSION access for the Review module, enabling testability and future session backend changes.

Tags
since
3.0.0

Table of Contents

Constants

KEY_CORRECT  = 'reviewcorrect'
KEY_REVIEW_KEY  = 'review_key'
Session keys used for review criteria.
KEY_SELECTION  = 'review_selection'
KEY_START  = 'reviewstart'
Session keys used for review state.
KEY_TOTAL  = 'reviewtotal'
KEY_WRONG  = 'reviewwrong'

Methods

clearAll()  : void
Clear all review data from session (criteria and progress).
clearCriteria()  : void
Clear review criteria from session.
clearSession()  : void
Clear the review session from PHP session.
getCriteria()  : array{reviewKey: string, selection: int|int[]}|null
Get review criteria from session.
getRawSessionData()  : array{start: int, total: int, correct: int, wrong: int}
Get raw session data (for backward compatibility).
getSelectionString()  : string
Get selection as string (for URL parameters).
getSession()  : ReviewSession|null
Get the current review session from PHP session.
hasCriteria()  : bool
Check if review criteria exists in session.
hasSession()  : bool
Check if a session exists.
initializeSession()  : void
Initialize a new review session with criteria and progress.
recordAnswer()  : void
Record an answer in the session.
saveCriteria()  : void
Save review criteria to session.
saveSession()  : void
Save the review session to PHP session.

Constants

KEY_REVIEW_KEY

Session keys used for review criteria.

private mixed KEY_REVIEW_KEY = 'review_key'

KEY_START

Session keys used for review state.

private mixed KEY_START = 'reviewstart'

Methods

clearAll()

Clear all review data from session (criteria and progress).

public clearAll() : void

clearSession()

Clear the review session from PHP session.

public clearSession() : void

getCriteria()

Get review criteria from session.

public getCriteria() : array{reviewKey: string, selection: int|int[]}|null
Return values
array{reviewKey: string, selection: int|int[]}|null

Criteria or null if not set

getRawSessionData()

Get raw session data (for backward compatibility).

public getRawSessionData() : array{start: int, total: int, correct: int, wrong: int}
Return values
array{start: int, total: int, correct: int, wrong: int}

getSelectionString()

Get selection as string (for URL parameters).

public getSelectionString() : string
Return values
string

Comma-separated IDs or empty string

hasCriteria()

Check if review criteria exists in session.

public hasCriteria() : bool
Return values
bool

True if criteria is set

hasSession()

Check if a session exists.

public hasSession() : bool
Return values
bool

initializeSession()

Initialize a new review session with criteria and progress.

public initializeSession(string $reviewKey, int|array<string|int, int> $selection, int $totalDue) : void
Parameters
$reviewKey : string

Review key type

$selection : int|array<string|int, int>

Selection value

$totalDue : int

Total words due for review

recordAnswer()

Record an answer in the session.

public recordAnswer(bool $correct) : void
Parameters
$correct : bool

Whether the answer was correct

saveCriteria()

Save review criteria to session.

public saveCriteria(string $reviewKey, int|array<string|int, int> $selection) : void

Stores the review key type and selection values instead of raw SQL. This is safer and allows proper validation of the criteria.

Parameters
$reviewKey : string

Review key type ('words', 'texts', 'lang', 'text')

$selection : int|array<string|int, int>

Selection value (ID or array of IDs)


        
On this page

Search results