CrudServiceLogic
extends ServiceLogic
in package
Class handles Crud logic.
Tags
Table of Contents
- $formBuilder : mixed
- Form builder
- $model : CrudServiceModel
- Model
- $authorizationProvider : AuthorizationProviderInterface
- Authorization provider
- $paramsFetcher : RequestParamsInterface
- Request params fetcher
- $securityProvider : ProviderInterface
- Security provider
- __construct() : mixed
- Constructor
- all() : array<string|int, mixed>
- Method returns all records
- connect() : array<string|int, mixed>
- Method creates connection
- createRecord() : array<string|int, mixed>
- Method creates user
- deleteFiltered() : mixed
- Method deletes filtered records
- deleteRecord() : int
- Method deletes the specified record
- exact() : array<string|int, mixed>
- Method returns exact record from the table
- exactList() : array<string|int, mixed>
- Method returns exact records from the table
- fields() : array<string|int, mixed>
- Fields descriptions
- getAuthorizationProvider() : AuthorizationProviderInterface
- Method returns security provider
- getDomainId() : int
- Method returns domain id
- getParamsFetcher() : RequestParamsInterface
- Method return params fetcher
- getRecords() : array<string|int, mixed>
- Method returns records
- getSecurityProvider() : ProviderInterface
- Method returns security provider
- getSelfId() : array<string|int, mixed>
- Method returns session user's id
- getSelfIdValue() : int
- Method returns self id
- getSelfLogin() : array<string|int, mixed>
- Method returns session user's login
- getSelfLoginValue() : string
- Method returns self login
- hasPermit() : bool
- Checking does user has permit
- lastRecords() : array<string|int, mixed>
- Method returns last $count records
- listRecord() : array<string|int, mixed>
- Method returns records
- loginAs() : array<string|int, mixed>
- Method allows to login under another user
- newRecordsSince() : array<string|int, mixed>
- Method returns all records created since $date
- recordsCount() : int
- Method returns records count
- recordsCountByField() : array<string|int, mixed>
- Method returns records count, grouped by the specified field
- setSecurityProvider() : void
- Method sets security provider
- setToken() : array<string|int, mixed>
- Method sets token
- updateRecord() : array<string|int, mixed>
- Method updates record and it's custom fields
- validatePermit() : void
- The same as hasPermit but throwing exception for session user no permit
- getParam() : mixed
- Method returns request parameter
- getSessionId() : string
- Method returns session id
- hasDomainId() : bool
- Method returns true if the modelhas 'domain_id' field
- updateBasicFields() : array<string|int, mixed>
- Method compiles basic update record
- fetchFields() : array<string|int, mixed>
- Method fetches fields for model manipulation
Properties
$formBuilder
Form builder
protected
mixed
$formBuilder
= false
$model
Model
protected
CrudServiceModel
$model
$authorizationProvider
Authorization provider
private
AuthorizationProviderInterface
$authorizationProvider
$paramsFetcher
Request params fetcher
private
RequestParamsInterface
$paramsFetcher
$securityProvider
Security provider
private
ProviderInterface
$securityProvider
Methods
__construct()
Constructor
public
__construct(RequestParamsInterface $paramsFetcher, ProviderInterface $securityProvider) : mixed
Parameters
- $paramsFetcher : RequestParamsInterface
-
Params fetcher
- $securityProvider : ProviderInterface
-
Security provider
Return values
mixed —all()
Method returns all records
public
all() : array<string|int, mixed>
Return values
array<string|int, mixed> —of records after all transformations
connect()
Method creates connection
public
connect() : array<string|int, mixed>
Return values
array<string|int, mixed> —session id
createRecord()
Method creates user
public
createRecord() : array<string|int, mixed>
Return values
array<string|int, mixed> —created record
deleteFiltered()
Method deletes filtered records
public
deleteFiltered() : mixed
Return values
mixed —deleteRecord()
Method deletes the specified record
public
deleteRecord() : int
Return values
int —id of the deleted record
exact()
Method returns exact record from the table
public
exact() : array<string|int, mixed>
Return values
array<string|int, mixed> —exact record
exactList()
Method returns exact records from the table
public
exactList() : array<string|int, mixed>
Return values
array<string|int, mixed> —exact list of records
fields()
Fields descriptions
public
fields() : array<string|int, mixed>
Return values
array<string|int, mixed> —Fields descriptions
getAuthorizationProvider()
Method returns security provider
public
abstract getAuthorizationProvider() : AuthorizationProviderInterface
Return values
AuthorizationProviderInterface —getDomainId()
Method returns domain id
public
getDomainId() : int
Return values
int —Domain id
getParamsFetcher()
Method return params fetcher
public
getParamsFetcher() : RequestParamsInterface
Return values
RequestParamsInterface —Params fetcher
getRecords()
Method returns records
public
getRecords(int $domainId, array<string|int, mixed> $order, int $from, int $limit) : array<string|int, mixed>
Parameters
- $domainId : int
-
Domain id
- $order : array<string|int, mixed>
-
Sorting settings
- $from : int
-
Starting record
- $limit : int
-
Fetch limit
Return values
array<string|int, mixed> —of records after all transformations
getSecurityProvider()
Method returns security provider
public
getSecurityProvider() : ProviderInterface
Return values
ProviderInterface —getSelfId()
Method returns session user's id
public
getSelfId() : array<string|int, mixed>
Return values
array<string|int, mixed> —session user's id
getSelfIdValue()
Method returns self id
public
getSelfIdValue() : int
Return values
int —session user's id
getSelfLogin()
Method returns session user's login
public
getSelfLogin() : array<string|int, mixed>
Return values
array<string|int, mixed> —session user's login
getSelfLoginValue()
Method returns self login
public
getSelfLoginValue() : string
Return values
string —session user's login
hasPermit()
Checking does user has permit
public
hasPermit(string $permit) : bool
Parameters
- $permit : string
-
permit to check
Return values
bool —true or false if the session user has permit or not
lastRecords()
Method returns last $count records
public
lastRecords() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of the last $count records
listRecord()
Method returns records
public
listRecord() : array<string|int, mixed>
Return values
array<string|int, mixed> —of records after all transformations
loginAs()
Method allows to login under another user
public
loginAs() : array<string|int, mixed>
Return values
array<string|int, mixed> —session id
newRecordsSince()
Method returns all records created since $date
public
newRecordsSince() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of records created since $date
recordsCount()
Method returns records count
public
recordsCount() : int
Return values
int —Records count
recordsCountByField()
Method returns records count, grouped by the specified field
public
recordsCountByField() : array<string|int, mixed>
Return values
array<string|int, mixed> —records count
setSecurityProvider()
Method sets security provider
public
setSecurityProvider(ProviderInterface $securityProvider) : void
Parameters
- $securityProvider : ProviderInterface
Return values
void —setToken()
Method sets token
public
setToken() : array<string|int, mixed>
Return values
array<string|int, mixed> —Session id
updateRecord()
Method updates record and it's custom fields
public
updateRecord() : array<string|int, mixed>
Return values
array<string|int, mixed> —Updated fields and their new values
validatePermit()
The same as hasPermit but throwing exception for session user no permit
public
validatePermit(string $permit) : void
Parameters
- $permit : string
-
permit name
Return values
void —getParam()
Method returns request parameter
protected
getParam(string $param[, mixed $default = false ]) : mixed
Parameters
- $param : string
-
parameter name
- $default : mixed = false
-
default value
Return values
mixed —Parameter value
getSessionId()
Method returns session id
protected
getSessionId() : string
Return values
string —session id
hasDomainId()
Method returns true if the modelhas 'domain_id' field
protected
hasDomainId() : bool
Return values
bool —true if the modelhas 'domain_id' field, false otherwise
updateBasicFields()
Method compiles basic update record
protected
updateBasicFields(int $id) : array<string|int, mixed>
Parameters
- $id : int
-
Id of the updating record
Return values
array<string|int, mixed> —with updated fields
fetchFields()
Method fetches fields for model manipulation
private
fetchFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —fetched fields