ResourceMapper
extends Mapper
in package
Class ResourceMapper.
Mapper class for DB calls used for the resource table.
Table of Contents
- $db : ADOConnection
- DB connector.
- $logger : MonologWrapper
- Logger object.
- __construct() : mixed
- Mapper constructor.
- all() : array<string|int, mixed>
- Find all resources.
- delete() : bool
- Delete an API resource.
- findByAppId() : array<string|int, mixed>
- Find Resources by an application ID.
- findByAppIdMethodUri() : Resource
- Find a resource by application ID, method and URI.
- findByAppNamesMethodUri() : array<string|int, mixed>
- Find a resource by application name/s, method and uri.
- findByResid() : Resource
- Find a resource by its ID.
- findByUid() : array<string|int, mixed>
- Find Resources by user ID.
- findByUidRidAccidAppidResid() : array<string|int, mixed>
- Find resources for a user, based on uid and role, then filter by accid, appid & resid.
- save() : bool
- Save an API Resource.
- fetchRow() : mixed
- Perform an SQL statement that expects a single row.
- fetchRows() : array<string|int, mixed>
- Perform an SQL statement that expects multiple rows.
- mapArray() : resource
- Map a DB row to this object.
- saveDelete() : bool
- Perform a save or delete.
Properties
$db
DB connector.
protected
ADOConnection
$db
DB Instance.
$logger
Logger object.
protected
MonologWrapper
$logger
Methods
__construct()
Mapper constructor.
public
__construct(ADOConnection $dbLayer, MonologWrapper $logger) : mixed
Parameters
- $dbLayer : ADOConnection
-
DB connection object.
- $logger : MonologWrapper
-
Logger object.
Return values
mixed —all()
Find all resources.
public
all([array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed> = []
-
Filter and order params.
Tags
Return values
array<string|int, mixed> —Resource object.
delete()
Delete an API resource.
public
delete(Resource $resource) : bool
Parameters
- $resource : Resource
-
Resource object.
Tags
Return values
bool —Success.
findByAppId()
Find Resources by an application ID.
public
findByAppId(int|array<string|int, mixed> $appids[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $appids : int|array<string|int, mixed>
-
Application ID or an array of appid's.
- $params : array<string|int, mixed> = []
-
Filter and order params.
Tags
Return values
array<string|int, mixed> —Array of Resource objects.
findByAppIdMethodUri()
Find a resource by application ID, method and URI.
public
findByAppIdMethodUri(int $appid, string $method, string $uri) : Resource
Parameters
- $appid : int
-
Application ID.
- $method : string
-
API resource method.
- $uri : string
-
API resource URI.
Tags
Return values
Resource —Resource object.
findByAppNamesMethodUri()
Find a resource by application name/s, method and uri.
public
findByAppNamesMethodUri(array<string|int, mixed>|string $appNames, string $method, string $uri) : array<string|int, mixed>
Parameters
- $appNames : array<string|int, mixed>|string
-
Application name or array of application names.
- $method : string
-
Resource method.
- $uri : string
-
Resource uri.
Tags
Return values
array<string|int, mixed> —Array of Resource objects.
findByResid()
Find a resource by its ID.
public
findByResid(int $resid) : Resource
Parameters
- $resid : int
-
Resource ID.
Tags
Return values
Resource —Resource object.
findByUid()
Find Resources by user ID.
public
findByUid(int $uid[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $uid : int
-
Application ID or an array of appid's.
- $params : array<string|int, mixed> = []
-
Filter and order params.
Tags
Return values
array<string|int, mixed> —Array of Resource objects.
findByUidRidAccidAppidResid()
Find resources for a user, based on uid and role, then filter by accid, appid & resid.
public
findByUidRidAccidAppidResid(int $uid, int $rid, int $accid, int $appid, int $resid, array<string|int, mixed> $params) : array<string|int, mixed>
Parameters
- $uid : int
-
User ID.
- $rid : int
-
Role ID.
- $accid : int
-
Account ID.
- $appid : int
-
Application ID.
- $resid : int
-
Resource ID.
- $params : array<string|int, mixed>
-
Filter params (keyword, order by, direction and limit).
Tags
Return values
array<string|int, mixed> —of Resource objects.
save()
Save an API Resource.
public
save(Resource $resource) : bool
Parameters
- $resource : Resource
-
The API Resource.
Tags
Return values
bool —Success.
fetchRow()
Perform an SQL statement that expects a single row.
protected
fetchRow(string $sql, array<string|int, mixed> $bindParams) : mixed
Parameters
- $sql : string
-
Query string.
- $bindParams : array<string|int, mixed>
-
Array of bind params.
Tags
Return values
mixed —Mapped row.
fetchRows()
Perform an SQL statement that expects multiple rows.
protected
fetchRows(string $sql[, array<string|int, mixed> $bindParams = [] ][, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $sql : string
-
Query string.
- $bindParams : array<string|int, mixed> = []
-
Array of bind params.
- $params : array<string|int, mixed> = []
-
Parameters (optional). Example: [ 'filter' => [ 'keyword' => string, 'column' => string, ] 'order_by' => string, 'direction' => string "ASC"|"DESC", 'offset' => int, 'limit' => int, ] NOTE: * This will throw an exception if the sql already contains a WHERE clause and should be calculated separately in these cases. * ['filter']['keyword'] '%' characters in keyword not added to keyword automatically.
Tags
Return values
array<string|int, mixed> —Array of mapped rows.
mapArray()
Map a DB row to this object.
protected
mapArray(array<string|int, mixed> $row) : resource
Parameters
- $row : array<string|int, mixed>
-
DB row object.
Return values
resource —Resource object.
saveDelete()
Perform a save or delete.
protected
saveDelete(string $sql, array<string|int, mixed> $bindParams) : bool
Parameters
- $sql : string
-
Query string.
- $bindParams : array<string|int, mixed>
-
Array of bind params.
Tags
Return values
bool —Success status.