• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/copy/integration/groupstepper.php
  • Класс: BitrixLandingCopyIntegrationGroupStepper
  • Вызов: GroupStepper::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();
		}

		$executiveUserId = ($queueOption["executiveUserId"] ?: 0);

		$siteId = ($queueOption['siteId'] ?: 0);
		$copiedSiteId = ($queueOption['copiedSiteId'] ?: 0);

		LandingRights::setContextUserId($executiveUserId);

		Type::setScope(Type::SCOPE_CODE_GROUP);

		$copiedPageIds = $this->getPageIdsBySiteId($copiedSiteId);
		$offset = count($copiedPageIds);

		$pageIdsToCopy = $this->getPageIdsBySiteId($siteId);
		$count = count($pageIdsToCopy);
		$pageIdsToCopy = array_slice($pageIdsToCopy, $offset, self::LIMIT);

		if ($pageIdsToCopy)
		{
			$pageCopier = $this->getPageCopier($copiedSiteId);

			$containerCollection = new ContainerCollection();
			foreach ($pageIdsToCopy as $pageId)
			{
				$container = new Container($pageId);
				$containerCollection[] = $container;
			}
			$result = $pageCopier->copy($containerCollection);
			if (!$result->isSuccess())
			{
				$this->deleteQueueOption();
				return !$this->isQueueEmpty();
			}

			$this->saveCopiedMapIds($pageCopier, $queueOption, $result);

			$option['count'] = $count;
			$option['steps'] = $offset;
		}
		else
		{
			$this->onAfterCopy($queueOption);
			$this->deleteQueueOption();
			return !$this->isQueueEmpty();
		}

		return true;
	}
	catch (Exception $exception)
	{
		$this->clearContextUserId();
		$this->writeToLog($exception);
		$this->deleteQueueOption();
		return false;
	}
}