• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/lib/integration/rest/appconfiguration.php
  • Класс: BitrixBizprocIntegrationRestAppConfiguration
  • Вызов: AppConfiguration::importBizproc
static function importBizproc($importData)
{
	$result = [];

	if (!isset($importData['CONTENT']['DATA']))
	{
		return false;
	}
	$item = $importData['CONTENT']['DATA'];
	if (
		in_array($item['MODULE_ID'], static::$accessModules)
		&& Loader::includeModule($item['MODULE_ID'])
		&& class_exists($item['ENTITY'])
	)
	{
		if (is_subclass_of($item['ENTITY'], '\IBPWorkflowDocument'))
		{

			if (isset($importData['RATIO']['CRM_STATUS']))
			{
				if (is_array($item['TEMPLATE_DATA']))
				{
					$item['TEMPLATE_DATA'] = static::changeDealCategory($item['TEMPLATE_DATA'], $importData['RATIO']['CRM_STATUS']);
				}
				if ($item['DOCUMENT_TYPE'] == 'DEAL' && $item['DOCUMENT_STATUS'])
				{
					$item['DOCUMENT_STATUS'] = static::changeDealCategory($item['DOCUMENT_STATUS'], $importData['RATIO']['CRM_STATUS']);
				}
			}

			try
			{
				$code = static::$context . '_xml_' . intval($item['ID']);
				$id = CBPWorkflowTemplateLoader::importTemplateFromArray(
					0,
					[
						$item['MODULE_ID'],
						$item['ENTITY'],
						$item['DOCUMENT_TYPE'],
					],
					$item['AUTO_EXECUTE'],
					$item['NAME'],
					isset($item['DESCRIPTION']) ? (string)$item['DESCRIPTION'] : '',
					$item['TEMPLATE_DATA'],
					$code
				);

				if ($id > 0)
				{
					$result['OWNER'] = [
						'ENTITY_TYPE' => self::OWNER_ENTITY_TYPE_BIZPROC,
						'ENTITY' => $id,
					];

					if ($item['DOCUMENT_STATUS'])
					{
						CBPWorkflowTemplateLoader::update(
							$id,
							[
								'DOCUMENT_STATUS' => $item['DOCUMENT_STATUS'],
							]
						);
					}
				}
			}
			catch (Exception $e)
			{
				$result['ERROR_ACTION'] = $e->getMessage();
				$result['ERROR_MESSAGES'] = Loc::getMessage(
					'BIZPROC_ERROR_CONFIGURATION_IMPORT_EXCEPTION_BP'
				);
			}
		}
	}

	return $result;
}