- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/scrum/service/itemservice.php
- Класс: BitrixTasksScrumServiceItemService
- Вызов: ItemService::moveItemsToEntity
public function moveItemsToEntity(array $itemIds, int $entityId, PushService $pushService = null): void
{
if (empty($itemIds))
{
return;
}
try
{
$sortInfo = [];
foreach ($itemIds as $key => $itemId)
{
$sortInfo[$itemId] = [
'sort' => $key + 1,
'entityId' => $entityId,
'updatedItemId' => $itemId,
];
}
$limit = count($itemIds);
$queryObject = ItemTable::getList([
'select' => ['ID', 'SORT'],
'filter' => ['ENTITY_ID' => $entityId],
'order' => ['SORT' => 'ASC', 'ID' => 'DESC'],
'limit' => $limit,
]);
while ($itemData = $queryObject->fetch())
{
$sortInfo[$itemData['ID']] = [
'sort' => $itemData['SORT'] + $limit,
'entityId' => $entityId,
'updatedItemId' => $itemData['ID'],
];
}
$this->sortItems($sortInfo, $pushService);
}
catch (Exception $exception)
{
$this->errorCollection->setError(
new Error(
$exception->getMessage(),
self::ERROR_COULD_NOT_MOVE_ITEM
)
);
}
}