• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/update/templateconverter.php
  • Класс: Bitrix\Tasks\Update\TemplateConverter
  • Вызов: TemplateConverter::run
private function run()
{
	if (!Loader::includeModule('tasks'))
	{
		$this->convertDone();
		return '';
	}

	$templates = $this->getList();
	if (empty($templates))
	{
		$this->convertDone();
		return '';
	}

	$members = [];
	$tags = [];
	$dependencies = [];
	foreach ($templates as $template)
	{
		$members = array_merge($members, $this->readMembers($template));
		$tags = array_merge($tags, $this->readTags($template));
		$dependencies = array_merge($dependencies, $this->readDependencies($template));
	}

	try
	{
		$this->saveMembers($members);
		$this->saveTags($tags);
		$this->saveDependencies($dependencies);
	}
	catch (\Exception $e)
	{
		(new Log())->collect('Unable to convert templates. '.$e->getMessage());
		return '';
	}


	if (count($templates) < self::LIMIT)
	{
		$this->convertDone();
		return '';
	}

	Option::set('tasks', self::OPTION_KEY, (int) $template['ID'], '-');

	return self::getAgentName();
}