- Модуль: lists
- Путь к файлу: ~/bitrix/modules/lists/lib/copy/integration/groupstepper.php
- Класс: BitrixListsCopyIntegrationGroupStepper
- Вызов: GroupStepper::execute
public function execute(array &$option)
{
if (!Loader::includeModule(self::$moduleId))
{
return false;
}
try
{
$queue = $this->getQueue();
$this->setQueue($queue);
$queueOption = $this->getQueueOption();
if (empty($queueOption))
{
$this->deleteQueueOption();
return !$this->isQueueEmpty();
}
$groupId = ($queueOption["groupId"] ?: 0);
$copiedGroupId = ($queueOption["copiedGroupId"] ?: 0);
$iblockTypeId = ($queueOption["iblockTypeId"] ?: "");
$errorOffset = ($queueOption["errorOffset"] ?: 0);
$limit = 5;
$offset = $this->getOffset($iblockTypeId, $copiedGroupId) + $errorOffset;
$iblockIds = $this->getIblockIdsToCopy($iblockTypeId, $groupId);
$count = count($iblockIds);
$iblockIds = array_slice($iblockIds, $offset, $limit);
$features = ($queueOption["features"] ?: []);
if ($iblockIds)
{
$option["count"] = $count;
$copyManager = new Manager($iblockTypeId, $iblockIds, $groupId);
$copyManager->setTargetLocation($iblockTypeId, $copiedGroupId);
$copyManager->setIblockImplementer(new Iblock());
$copyManager->setFieldImplementer(new Field());
$copyManager->setWorkflowImplementer(new Workflow($iblockTypeId));
if (!in_array("field", $features))
{
$copyManager->removeFeature("field");
}
if (!in_array("section", $features))
{
$copyManager->removeFeature("section");
}
if (!in_array("element", $features))
{
$copyManager->removeFeature("element");
}
if (!in_array("workflow", $features))
{
$copyManager->removeFeature("workflow");
}
$result = $copyManager->startCopy();
if (!$result->isSuccess())
{
$queueOption["errorOffset"] += $this->getErrorOffset($copyManager);
$this->saveQueueOption($queueOption);
}
$option["steps"] = $offset;
return true;
}
else
{
$this->deleteQueueOption();
return !$this->isQueueEmpty();
}
}
catch (Exception $exception)
{
$this->writeToLog($exception);
$this->deleteQueueOption();
return false;
}
}