Command
Description
abstract class Bitrix\Rpa\Command
- base class for updating items.
To avoid excessive and redundant logic for elements, all checks, preparations, launch of automation rules and etc. are moved to to this class.
Its an abstract class that has three descendants:
Constants
public const ERROR_CODE_ITEM_MOVE_PERMISSION = 'RPA_ITEM_MOVE_ACCESS_DENIED'
;public const ERROR_CODE_ITEM_MODIFY_PERMISSION = 'RPA_ITEM_MODIFY_ACCESS_DENIED'
;public const ERROR_CODE_WRONG_STAGE = 'RPA_ITEM_WRONG_STAGE'
;public const ERROR_CODE_MANDATORY_FIELD_EMPTY = 'RPA_MANDATORY_FIELD_EMPTY'
;public const ERROR_CODE_ITEM_USER_HAS_TASKS = 'RPA_ITEM_USER_HAS_TASKS'
;public const ERROR_CODE_ITEM_TASKS_NOT_COMPLETED = 'RPA_ITEM_TASKS_NOT_COMPLETED'
;public const ERROR_CODE_ITEM_DELETE_PERMISSION = 'RPA_ITEM_DELETE_PERMISSION'
.
These constants contain error codes that can be returned during command execution
Methods
Method | Description | Available from version |
---|---|---|
public function __construct(Item $item, array $data = []) |
Constructor.
Receives an item and array of parameters
All this data has getters and setters. Passing to constructor is optional:
|
|
public function run(): Result |
Main command method.
This method performs the following:
During the moment of launching the automation rules other actions can be performed with the item that will raise new command instance. All checks are enabled by default All checks are executed sequentially, if they were not disabled. When an error occurs during one of checks, command interruption is terminated. Separate set of methods is available for enabling/disabling
Additionally, you can disable automatic actions executed after modification are saved:
|
|
public function setPullEventId(string $eventId): Command |
Allows specifying event ID for \Bitrix\Rpa\Integration\PullManager. | |
abstract public function checkStage(): Result; |
Executes stage check. Defined in descendants. | |
abstract public function checkAccess(): Result; |
Executes access permission check. Defined in descendants. | |
public function checkTasks(): Result |
Executes check of launched tasks. Does nothing by default, defined only in Bitrix\Rpa\Command\Update. | |
public function saveToHistory(ItemHistory $historyRecord): Result |
Saves data into revision history table. | |
public function checkFields(): Result |
Executes field check. In Bitrix\Rpa\Command\Add this method is empty and fields are not changed when deleting. | |
public function checkRequiredFields(UserFieldCollection $userFieldCollection): Result |
Checks if all required fields from collection $userFieldCollection are filled. | |
public function resetNotEditableFields(UserFieldCollection $userFieldCollection): Result |
Resets item's user field values from collection $userFieldCollection that cannot be edited. | |
public function isTerminated(): bool |
Automatic task completion mode can be triggered during execution of method checkTasks in [link=11338782]Bitrix\Rpa\Command\Update[/link].
In this case, further command execution does not have sense, because item was updated and modified again. And command execution must be terminated. This method returns |