• Модуль: learning
  • Путь к файлу: ~/bitrix/modules/learning/lib/integration/search.php
  • Класс: BitrixLearningIntegrationSearch
  • Вызов: Search::handleReindex
static function handleReindex($nextStep = [], $callbackObject = null, $callbackMethod = "")
{
	$result = array();
	$elementStartId = 0;
	$indexElementType = "C"; // start reindex from courses

	if (isset($nextStep["ID"]) && $nextStep["ID"] <> '')
	{
		$indexElementType = mb_substr($nextStep["ID"], 0, 1);
		$elementStartId = intval(mb_substr($nextStep["ID"], 1));
	}

	if ($indexElementType === "C")
	{
		$dbCourse = CCourse::getList(["ID" => "ASC"], [">ID" => $elementStartId]);
		while ($course = $dbCourse->fetch())
		{
			$linkedLessonId = CCourse::courseGetLinkedLesson($course["ID"]);
			if ($linkedLessonId === false)
			{
				continue;
			}

			$res = true;
			$items = static::getIndexItems($linkedLessonId);

			foreach ($items as $item)
			{
				if ($callbackObject)
				{
					$res &= call_user_func(array($callbackObject, $callbackMethod), $item);
				}
				else
				{
					$result[] = $item;
				}
			}

			if (!$res)
			{
				return ("C".$course["ID"]);
			}
		}

		// Reindex of courses finished. Let's reindex lessons now.
		$indexElementType = "U";
		$elementStartId = 0;
	}

	if ($indexElementType === "U")
	{
		$dbLessons = CLearnLesson::getList(
			["LESSON_ID" => "ASC"],
			["LINKED_LESSON_ID" => "", ">LESSON_ID" => $elementStartId]
		);

		while ($lesson = $dbLessons->fetch())
		{
			$res = true;
			$items = static::getIndexItems($lesson["LESSON_ID"]);

			foreach ($items as $item)
			{
				if ($callbackObject)
				{
					$res &= call_user_func(array($callbackObject, $callbackMethod), $item);
				}
				else
				{
					$result[] = $item;
				}
			}

			if (!$res)
			{
				return ("U".$lesson["LESSON_ID"]);
			}
		}
	}

	return !empty($result) ? $result : false;
}