• Модуль: iblock
  • Путь к файлу: ~/bitrix/modules/iblock/lib/copy/stepper/iblock.php
  • Класс: BitrixIblockCopyStepperIblock
  • Вызов: Iblock::execute
public function execute(array &$option)
{
	if (!Loader::includeModule(self::$moduleId))
	{
		return false;
	}

	try
	{
		$queue = $this->getQueue();
		$this->setQueue($queue);
		$queueOption = $this->getOptionData($this->baseName);
		if (empty($queueOption))
		{
			$this->deleteQueueOption();
			return !$this->isQueueEmpty();
		}

		$iblockId = ($queueOption["iblockId"] ?: 0);
		$copiedIblockId = ($queueOption["copiedIblockId"] ?: 0);
		$errorOffset = ($queueOption["errorOffset"] ?: 0);

		$limit = 5;
		$offset = $this->getOffset($copiedIblockId) + $errorOffset;

		$enumRatio = ($queueOption["enumRatio"] ?: []);
		$sectionsRatio = ($queueOption["sectionsRatio"] ?: []);
		$mapIdsCopiedElements = ($queueOption["mapIdsCopiedElements"] ?: []);

		if ($iblockId)
		{
			list($elementIds, $selectedRowsCount) = $this->getElementIds($iblockId, $limit, $offset);

			$elementCopier = $this->getElementCopier();
			$containerCollection = $this->getContainerCollection(
				$elementIds, $sectionsRatio, $enumRatio, $copiedIblockId);
			$result = $elementCopier->copy($containerCollection);
			if (!$result->isSuccess())
			{
				$queueOption["errorOffset"] += $this->getErrorOffset($elementCopier);
			}

			$mapIdsCopiedElements = $elementCopier->getMapIdsCopiedEntity() + $mapIdsCopiedElements;
			$queueOption["mapIdsCopiedElements"] = $mapIdsCopiedElements;
			$this->saveQueueOption($queueOption);

			if ($selectedRowsCount < $limit)
			{
				$this->deleteQueueOption();
				$this->onAfterCopy($queueOption);
				return !$this->isQueueEmpty();
			}
			else
			{
				$option["steps"] = $offset;
				return true;
			}
		}
		else
		{
			$this->deleteQueueOption();
			return !$this->isQueueEmpty();
		}
	}
	catch (Exception $exception)
	{
		$this->writeToLog($exception);
		$this->deleteQueueOption();
		return false;
	}
}