- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/internals/database/structure/closuretree/fragment.php
- Класс: BitrixTasksInternalsDataBaseStructureClosureTreeFragment
- Вызов: Fragment::walkWidth
public function walkWidth($cb, $rootId = 0)
{
$result = new Result();
if(!is_callable($cb))
{
return $result;
}
$index = $this->getIndex();
$data = array();
$rootId = intval($rootId);
$queue = array($rootId);
$met = array();
$limit = 0;
while(count($queue))
{
$limit++;
if($limit > 10000)
{
break;
}
$nextId = array_shift($queue);
if(isset($met[$nextId]))
{
continue; // do not go the same way twice
}
$met[$nextId] = true;
if($nextId)
{
$data[$nextId] = call_user_func_array(
$cb,
array(
null/** todo: object will be here some day, on which we can do ->getParentId() or even ->getParent() */,
$nextId,
$this->values[$nextId] ?? null,
$this->getParentIdFor($nextId)
)
);
}
if(array_key_exists($nextId, $index))
{
foreach($index[$nextId] as $subNodeId => $subNode)
{
array_push($queue, $subNodeId);
}
}
}
$result->setData($data);
if($limit > 10000)
{
$result->addError('ILLEGAL_STRUCTURE.DEPTH', 'Illegal fragment structure');
}
return $result;
}