GetService
CBPRuntimeService
public function GetService($name)( string name
);
This method returns a runtime service instance by its name. The following runtime services are available.
Name | Class | Description |
---|---|---|
SchedulerService | CBPSchedulerService | Works to install an agent which will be executed within specified time and will send external event to an indicated workflow |
StateService | CBPStateService | Designed to handle workflow status, saved in the database |
TrackingService | CBPTrackingService | Designed to record messages to log |
TaskService | CBPTaskService | Designed to work with tasks |
HistoryService | CBPHistoryService | Designed to work with document revision history |
DocumentService | CBPDocumentService | Designed to work with document |
Method parameters
Parameter | Description |
---|---|
name | Service name |
Returned value
Returns service class, inherited from CBPRuntimeService.
Examples
<?
// Save document $documentId history on behalf of user $userId
$runtime = CBPRuntime::GetRuntime();
$historyService = $runtime->GetService("HistoryService");
$documentService = $runtime->GetService("DocumentService");
$historyIndex = $historyService->AddHistory(
array(
"DOCUMENT_ID" => $documentId,
"NAME" => "New",
"DOCUMENT" => null,
"USER_ID" => $userId,
)
);
$arDocument = $documentService->GetDocumentForHistory($documentId, $historyIndex);
if (is_array($arDocument))
{
$historyService->UpdateHistory(
$historyIndex,
array(
"NAME" => $arDocument["NAME"],
"DOCUMENT" => $arDocument,
)
);
}
?>
© «Bitrix24», 2001-2024