LoginToken
extends Gateway
in package
Uses
ExpirationTrait
Table Definition for login_token
Tags
Table of Contents
- $tableManager : PluginManager
- Table manager
- __construct() : mixed
- Constructor
- beginTransaction() : void
- Begin a database transaction.
- commitTransaction() : void
- Commit a database transaction.
- createRow() : object
- Create a new row.
- deleteBySeries() : void
- Delete all tokens in a given series
- deleteByUserId() : void
- Delete all tokens for a user
- deleteExpired() : int
- Delete expired records. Allows setting of 'from' and 'to' ID's so that rows can be deleted in small batches.
- getBySeries() : ResultSetInterface
- Get token by series
- getByUserId() : array<string|int, mixed>
- Get tokens for a given user
- getDbTable() : Gateway
- Get access to another table.
- initializeFeatures() : void
- Initialize features
- matchToken() : LoginToken|null
- Check if a login token matches one in database.
- rollBackTransaction() : void
- Roll back a database transaction.
- expirationCallback() : void
- Update the select statement to find records to delete.
- getExpiredBatchLastId() : int|null
- Get the highest id to delete in a batch.
Properties
$tableManager
Table manager
protected
PluginManager
$tableManager
Methods
__construct()
Constructor
public
__construct(Adapter $adapter, PluginManager $tm, array<string|int, mixed> $cfg[, RowGateway $rowObj = null ][, string $table = 'login_token' ]) : mixed
Parameters
- $adapter : Adapter
-
Database adapter
- $tm : PluginManager
-
Table manager
- $cfg : array<string|int, mixed>
-
Laminas configuration
- $rowObj : RowGateway = null
-
Row prototype object (null for default)
- $table : string = 'login_token'
-
Name of database table to interface with
Return values
mixed —beginTransaction()
Begin a database transaction.
public
beginTransaction() : void
Tags
Return values
void —commitTransaction()
Commit a database transaction.
public
commitTransaction() : void
Tags
Return values
void —createRow()
Create a new row.
public
createRow() : object
Return values
object —deleteBySeries()
Delete all tokens in a given series
public
deleteBySeries(string $series[, int|null $currentTokenId = null ]) : void
Parameters
- $series : string
-
series
- $currentTokenId : int|null = null
-
Current token ID to keep
Return values
void —deleteByUserId()
Delete all tokens for a user
public
deleteByUserId(int $userId) : void
Parameters
- $userId : int
-
user identifier
Return values
void —deleteExpired()
Delete expired records. Allows setting of 'from' and 'to' ID's so that rows can be deleted in small batches.
public
deleteExpired(string $dateLimit[, int|null $limit = null ]) : int
Parameters
- $dateLimit : string
-
Date threshold of an "expired" record in format 'Y-m-d H:i:s'.
- $limit : int|null = null
-
Maximum number of rows to delete or null for no limit.
Return values
int —Number of rows deleted
getBySeries()
Get token by series
public
getBySeries(string $series) : ResultSetInterface
Parameters
- $series : string
-
Series identifier
Return values
ResultSetInterface —getByUserId()
Get tokens for a given user
public
getByUserId(int $userId[, bool $grouped = true ]) : array<string|int, mixed>
Parameters
- $userId : int
-
User identifier
- $grouped : bool = true
-
Whether to return results grouped by series
Return values
array<string|int, mixed> —getDbTable()
Get access to another table.
public
getDbTable(string $table) : Gateway
Parameters
- $table : string
-
Table name
Return values
Gateway —initializeFeatures()
Initialize features
public
initializeFeatures(array<string|int, mixed> $cfg) : void
Parameters
- $cfg : array<string|int, mixed>
-
Laminas configuration
Return values
void —matchToken()
Check if a login token matches one in database.
public
matchToken(array<string|int, mixed> $token) : LoginToken|null
Parameters
- $token : array<string|int, mixed>
-
array containing user id, token and series
Tags
Return values
LoginToken|null —rollBackTransaction()
Roll back a database transaction.
public
rollBackTransaction() : void
Tags
Return values
void —expirationCallback()
Update the select statement to find records to delete.
protected
expirationCallback(Select $select, string $dateLimit) : void
Parameters
- $select : Select
-
Select clause
- $dateLimit : string
-
Date threshold of an "expired" record in format 'Y-m-d H:i:s'.
Tags
Return values
void —getExpiredBatchLastId()
Get the highest id to delete in a batch.
protected
getExpiredBatchLastId(string $dateLimit, int $limit) : int|null
Parameters
- $dateLimit : string
-
Date threshold of an "expired" record in format 'Y-m-d H:i:s'.
- $limit : int
-
Maximum number of rows to delete.
Return values
int|null —Highest id value to delete or null if a limiting id is not available