• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Collection.php
  • Класс: BitrixImV2Collection
  • Вызов: Collection::save
public function save(bool $isGroupSave = false): Result
{
	$result = $this->prepareFields();

	if ($result->isSuccess())
	{
		if ($isGroupSave)
		{
			$resultSave = $this->getDataEntityCollection()->save(true);
			if (!$resultSave->isSuccess())
			{
				$result->addErrors($resultSave->getErrors());
			}
		}
		else
		{
			$index = [];
			foreach ($this as $inx => $entity)
			{
				$index[] = $inx;
			}

			/** @var ActiveRecord $entity */
			foreach ($index as $inx)
			{
				$entity = $this[$inx];
				if ($entity instanceof RegistryEntry)
				{
					$entity->setRegistry($this);
				}
				$resultSave = $entity->save();
				if (!$resultSave->isSuccess())
				{
					$result->addErrors($resultSave->getErrors());
				}
				elseif ($inx < 0 && isset($this[$entity->getPrimaryId()]))
				{
					unset($this[$inx]);// remove temporary object link from registry
				}
			}
		}
	}

	return $result;
}