Command
Class Command
Table of Contents
Constants
- ERROR_CALLBACK = 400
- ERROR_CONNECTION = 50
- ERROR_CONNECTION_COUNT = 51
- ERROR_CONNECTION_RESPONSE = 60
- ERROR_CONTROLLER_AFTER_DOWNLOAD_SIZE = 202
- ERROR_CONTROLLER_BACK_URL_HOST_MISMATCH = 156
- ERROR_CONTROLLER_BANNED = 103
- ERROR_CONTROLLER_COMMAND_ERROR = 303
- ERROR_CONTROLLER_COMMAND_NOT_FOUND = 302
- ERROR_CONTROLLER_DOMAIN_IS_PRIVATE = 157
- ERROR_CONTROLLER_DOWNLOAD = 201
- ERROR_CONTROLLER_DOWNLOAD_SIZE = 102
- ERROR_CONTROLLER_DOWNLOAD_STATUS = 100
- ERROR_CONTROLLER_DOWNLOAD_TYPE = 101
- ERROR_CONTROLLER_LIMIT_EXCEED = 155
- ERROR_CONTROLLER_MODULE_NOT_INSTALLED = 153
- ERROR_CONTROLLER_QUEUE_ADD_FAIL = 151
- ERROR_CONTROLLER_QUEUE_CANCELED_BY_EVENT = 150
- ERROR_CONTROLLER_QUEUE_NOT_FOUND = 152
- ERROR_CONTROLLER_RIGHT_CHECK_FAILED = 154
- ERROR_CONTROLLER_STATUS_AFTER_DOWNLOAD = 200
- ERROR_CONTROLLER_TRANSFORMATION = 300
- ERROR_CONTROLLER_TRANSFORMATION_COMMAND = 301
- ERROR_CONTROLLER_TRANSFORMATION_TIMED_OUT = 304
- ERROR_CONTROLLER_UNKNOWN_ERROR = 250
- ERROR_CONTROLLER_UPLOAD = 203
- ERROR_CONTROLLER_URL_INVALID = 158
- ERROR_CORRUPTED_FILE = 30
- ERROR_DEADLINE_EXCEEDED = 70
- ERROR_EMPTY_CONTROLLER_URL = 40
- STATUS_CREATE = 100
- STATUS_ERROR = 1000
- STATUS_SEND = 200
- STATUS_SUCCESS = 400
- STATUS_UPLOAD = 300
Methods
- __construct() : mixed
- Command constructor.
- callback() : bool
- Include modules and call all the callbacks. Return true on success of all callbacks.
- getByFile() : Command|bool
- Get last command from DB on $file.
- getByGuid() : Command|bool
- Get command from DB on $guid.
- getCommandName() : string
- getControllerUrl() : string|null
- getDeadline() : DateTime|null
- getError() : Error|null
- getFileSize() : int|null
- getGuid() : string|null
- getId() : int
- Get id of the command
- getParams() : array<string|int, mixed>
- getQueue() : string|null
- getSendTime() : DateTime|null
- getStatus() : int
- Get current status of the command.
- getStatusText() : int|string
- Get text description of the status.
- getTime() : null|DateTime
- Get update time of the command.
- push() : mixed
- Adds new record to push&pull
- save() : AddResult
- Save command in DB.
- send() : Result
- Check current status of the command and send it through $http.
- updateStatus() : UpdateResult
- Update status of command and save it in DB.
Constants
ERROR_CALLBACK
public
mixed
ERROR_CALLBACK
= 400
ERROR_CONNECTION
public
mixed
ERROR_CONNECTION
= 50
ERROR_CONNECTION_COUNT
public
mixed
ERROR_CONNECTION_COUNT
= 51
ERROR_CONNECTION_RESPONSE
public
mixed
ERROR_CONNECTION_RESPONSE
= 60
ERROR_CONTROLLER_AFTER_DOWNLOAD_SIZE
public
mixed
ERROR_CONTROLLER_AFTER_DOWNLOAD_SIZE
= 202
ERROR_CONTROLLER_BACK_URL_HOST_MISMATCH
public
mixed
ERROR_CONTROLLER_BACK_URL_HOST_MISMATCH
= 156
ERROR_CONTROLLER_BANNED
public
mixed
ERROR_CONTROLLER_BANNED
= 103
ERROR_CONTROLLER_COMMAND_ERROR
public
mixed
ERROR_CONTROLLER_COMMAND_ERROR
= 303
ERROR_CONTROLLER_COMMAND_NOT_FOUND
public
mixed
ERROR_CONTROLLER_COMMAND_NOT_FOUND
= 302
ERROR_CONTROLLER_DOMAIN_IS_PRIVATE
public
mixed
ERROR_CONTROLLER_DOMAIN_IS_PRIVATE
= 157
ERROR_CONTROLLER_DOWNLOAD
public
mixed
ERROR_CONTROLLER_DOWNLOAD
= 201
ERROR_CONTROLLER_DOWNLOAD_SIZE
public
mixed
ERROR_CONTROLLER_DOWNLOAD_SIZE
= 102
ERROR_CONTROLLER_DOWNLOAD_STATUS
public
mixed
ERROR_CONTROLLER_DOWNLOAD_STATUS
= 100
ERROR_CONTROLLER_DOWNLOAD_TYPE
public
mixed
ERROR_CONTROLLER_DOWNLOAD_TYPE
= 101
ERROR_CONTROLLER_LIMIT_EXCEED
public
mixed
ERROR_CONTROLLER_LIMIT_EXCEED
= 155
ERROR_CONTROLLER_MODULE_NOT_INSTALLED
public
mixed
ERROR_CONTROLLER_MODULE_NOT_INSTALLED
= 153
ERROR_CONTROLLER_QUEUE_ADD_FAIL
public
mixed
ERROR_CONTROLLER_QUEUE_ADD_FAIL
= 151
ERROR_CONTROLLER_QUEUE_CANCELED_BY_EVENT
public
mixed
ERROR_CONTROLLER_QUEUE_CANCELED_BY_EVENT
= 150
ERROR_CONTROLLER_QUEUE_NOT_FOUND
public
mixed
ERROR_CONTROLLER_QUEUE_NOT_FOUND
= 152
ERROR_CONTROLLER_RIGHT_CHECK_FAILED
public
mixed
ERROR_CONTROLLER_RIGHT_CHECK_FAILED
= 154
ERROR_CONTROLLER_STATUS_AFTER_DOWNLOAD
public
mixed
ERROR_CONTROLLER_STATUS_AFTER_DOWNLOAD
= 200
ERROR_CONTROLLER_TRANSFORMATION
public
mixed
ERROR_CONTROLLER_TRANSFORMATION
= 300
ERROR_CONTROLLER_TRANSFORMATION_COMMAND
public
mixed
ERROR_CONTROLLER_TRANSFORMATION_COMMAND
= 301
ERROR_CONTROLLER_TRANSFORMATION_TIMED_OUT
public
mixed
ERROR_CONTROLLER_TRANSFORMATION_TIMED_OUT
= 304
ERROR_CONTROLLER_UNKNOWN_ERROR
public
mixed
ERROR_CONTROLLER_UNKNOWN_ERROR
= 250
ERROR_CONTROLLER_UPLOAD
public
mixed
ERROR_CONTROLLER_UPLOAD
= 203
ERROR_CONTROLLER_URL_INVALID
public
mixed
ERROR_CONTROLLER_URL_INVALID
= 158
ERROR_CORRUPTED_FILE
public
mixed
ERROR_CORRUPTED_FILE
= 30
ERROR_DEADLINE_EXCEEDED
public
mixed
ERROR_DEADLINE_EXCEEDED
= 70
ERROR_EMPTY_CONTROLLER_URL
public
mixed
ERROR_EMPTY_CONTROLLER_URL
= 40
STATUS_CREATE
public
mixed
STATUS_CREATE
= 100
STATUS_ERROR
public
mixed
STATUS_ERROR
= 1000
STATUS_SEND
public
mixed
STATUS_SEND
= 200
STATUS_SUCCESS
public
mixed
STATUS_SUCCESS
= 400
STATUS_UPLOAD
public
mixed
STATUS_UPLOAD
= 300
Methods
__construct()
Command constructor.
public
__construct(string $command, array<string|int, mixed> $params, string|array<string|int, mixed> $module, string|array<string|int, mixed> $callback[, int $status = \self::STATUS_CREATE ][, string $id = '' ][, string $guid = '' ][, mixed $time = null ][, mixed $error = '' ][, mixed $errorCode = 0 ]) : mixed
Parameters
- $command : string
-
Class name of the controller.
- $params : array<string|int, mixed>
-
Params to be passed.
- $module : string|array<string|int, mixed>
-
Module name (one or array) to be included before callback.
- $callback : string|array<string|int, mixed>
-
Callback (one or array) to be called with results.
- $status : int = \self::STATUS_CREATE
-
Current status.
- $id : string = ''
-
Primary key.
- $guid : string = ''
-
Unique key of the command.
- $time : mixed = null
- $error : mixed = ''
- $errorCode : mixed = 0
Tags
callback()
Include modules and call all the callbacks. Return true on success of all callbacks.
public
callback([array<string|int, mixed> $result = [] ]) : bool
If at least one of callbacks returned false, this method return false.
Parameters
- $result : array<string|int, mixed> = []
-
Result from the controller.
Return values
boolgetByFile()
Get last command from DB on $file.
public
static getByFile(string $file) : Command|bool
Parameters
- $file : string
-
Path to the file command had been created with.
Tags
Return values
Command|boolgetByGuid()
Get command from DB on $guid.
public
static getByGuid(string $guid) : Command|bool
Parameters
- $guid : string
-
Unique key to get Command from DB.
Tags
Return values
Command|boolgetCommandName()
public
final getCommandName() : string
Return values
stringgetControllerUrl()
public
final getControllerUrl() : string|null
Return values
string|nullgetDeadline()
public
final getDeadline() : DateTime|null
Return values
DateTime|nullgetError()
public
getError() : Error|null
Return values
Error|nullgetFileSize()
public
final getFileSize() : int|null
Return values
int|nullgetGuid()
public
final getGuid() : string|null
Return values
string|nullgetId()
Get id of the command
public
getId() : int
Return values
intgetParams()
public
getParams() : array<string|int, mixed>
Return values
array<string|int, mixed>getQueue()
public
final getQueue() : string|null
Return values
string|nullgetSendTime()
public
final getSendTime() : DateTime|null
Return values
DateTime|nullgetStatus()
Get current status of the command.
public
getStatus() : int
Return values
intgetStatusText()
Get text description of the status.
public
static getStatusText(int $status) : int|string
Parameters
- $status : int
-
Code of the status.
Return values
int|string —- status description.
getTime()
Get update time of the command.
public
getTime() : null|DateTime
Return values
null|DateTimepush()
Adds new record to push&pull
public
push() : mixed
save()
Save command in DB.
public
save() : AddResult
Tags
Return values
AddResultsend()
Check current status of the command and send it through $http.
public
send(Http $http) : Result
Parameters
- $http : Http
-
Class to send command.
Tags
Return values
ResultupdateStatus()
Update status of command and save it in DB.
public
updateStatus(int $status[, string $error = '' ][, int $errorCode = 0 ]) : UpdateResult
Parameters
- $status : int
-
CommandTable_STATUS.
- $error : string = ''
-
Error to save to DB.
- $errorCode : int = 0