- Модуль: bizproc
- Путь к файлу: ~/bitrix/modules/bizproc/lib/controller/debugger.php
- Класс: BitrixBizprocControllerDebugger
- Вызов: Debugger::fillAutomationViewAction
public function fillAutomationViewAction(string $sessionId): ?array
{
$session = $this->getSession($sessionId);
if (!$session)
{
return null;
}
$isBeforeDebuggerStartState = $session->isBeforeDebuggerStartState();
if ($isBeforeDebuggerStartState)
{
$documentId = null;
$documentType = $session->getParameterDocumentType();
}
else
{
[$documentId, $documentType] = $this->getActiveDocument($session);
if (!$documentId)
{
return null;
}
}
$documentService = CBPRuntime::GetRuntime(true)->getDocumentService();
/** @var AutomationTargetBaseTarget $target */
$target = $documentService->createAutomationTarget($documentType);
$target->setDocumentId($documentId);
[$status, $statusList] = $this->getStatus($target, $session);
$template = new Template($documentType, $status);
$documentFields = $isBeforeDebuggerStartState ? [] : $this->getDocumentFields($documentType);
$triggers = $target->getTriggers(array_keys($statusList));
$target->prepareTriggersToShow($triggers);
$workflowId = $target->getRuntime()->getCurrentWorkflowId();
$hasInstance = $workflowId && WorkflowInstanceTable::exists($workflowId);
$workflowStatus = $hasInstance ? CBPWorkflowStatus::Suspended : CBPWorkflowStatus::Completed;
$workflowEvents = [];
$debuggerState = Manager::getDebuggerState()->getId();
if ($hasInstance)
{
/** @var DebugWorkflow $workflow */
$workflow = CBPRuntime::GetRuntime(true)->getWorkflow($workflowId, true);
foreach ($workflow->getDebugEventIds() as $eventName)
{
foreach ($template->getRobots() as $robot)
{
if ($robot->getDelayName() === $eventName)
{
$workflowEvents[] = [
'name' => $eventName,
'sourceId' => $robot->getName(),
];
break;
}
}
}
}
$documentCategoryId =
$isBeforeDebuggerStartState
? $session->getDocumentCategoryId()
: $target->getDocumentCategory()
;
$documentValues =
$isBeforeDebuggerStartState
? []
: $this->getDocumentValues($documentType, $target->getComplexDocumentId(), $documentFields)
;
return [
'triggers' => $triggers,
'template' => AutomationComponentBase::getTemplateViewData($template->toArray(), $documentType),
'documentId' => $documentId,
'documentStatus' => $status,
'statusList' => array_values($statusList),
'documentCategoryId' => $documentCategoryId,
'documentFields' => array_values($documentFields),
'documentValues' => $documentValues,
'workflowId' => $workflowId,
'workflowStatus' => $workflowStatus,
'workflowEvents' => $workflowEvents,
'debuggerState' => $debuggerState,
'track' => $this->getTrack($workflowId, $workflowStatus),
'globalVariables' => array_values(AutomationHelper::getGlobalVariables($documentType)),
'globalConstants' => array_values(AutomationHelper::getGlobalConstants($documentType)),
];
}