• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/lib/Debugger/Session/WorkflowContext.php
  • Класс: BitrixBizprocDebuggerSessionWorkflowContext
  • Вызов: WorkflowContext::addAutomationShards
private function addAutomationShards(Template $template)
{
	$lastSavedTemplateShards = $this->findTemplateShards($template->getId());

	if (
		$lastSavedTemplateShards
		&& $template->getModified()
		&& $lastSavedTemplateShards->getModified()->toString() === $template->getModified()->toString()
	)
	{
		$this->setTemplateShardsId($lastSavedTemplateShards->getId());
	}
	else
	{
		$shards = [];
		foreach ($template->getRobots() as $robot)
		{
			$shards[] = $robot->toArray();
		}

		$templateShards = DebuggerSessionTemplateShardsTable::createObject();
		$templateShards
			->setShards($shards)
			->setModified($template->getModified())
			->setTemplateId($template->getId())
			->setTemplateType(TemplateShards::TEMPLATE_TYPE_ROBOTS)
		;

		$savingResult = $templateShards->save();
		$this->setTemplateShardsId($savingResult->getId());
	}
}