• Модуль: report
  • Путь к файлу: ~/bitrix/modules/report/lib/visualconstructor/internal/model.php
  • Класс: BitrixReportVisualConstructorInternaldeveloped
  • Вызов: developed::save
public function save()
{

	$referenceMapAttributes = static::getMapReferenceAttributes();

	foreach ($referenceMapAttributes as $referenceAttributeName => $assoc)
	{
		if (!empty($this->{$referenceAttributeName}))
		{
			switch ($assoc['type'])
			{
				case Common::MANY_TO_ONE:
					$this->saveManyToOneReference($this->{$referenceAttributeName}, $assoc);
					break;
				case Common::ONE_TO_ONE:
					//TODO:
					break;
			}
		}
	}

	$ormFields = $this->getConvertedMapAttributesToOrmFields();
	if (!$ormFields['ID'])
	{
		$addResult = $this->add($ormFields);
		$ownerId = $addResult->getId();
		$this->setId($ownerId);
	}
	else
	{
		$ownerId = $ormFields['ID'];
		$changedAttributes = $this->getChangedOrmAttributes($ormFields);
		if ($changedAttributes)
		{
			$this->update(array('ID' => $ownerId), $changedAttributes);
		}
		if (!empty($this->deletedEntities))
		{
			$this->deleteReference($this->deletedEntities);
		}
	}




	foreach ($referenceMapAttributes as $referenceAttributeName => $assoc)
	{
		if (!empty($this->{$referenceAttributeName}))
		{
			switch ($assoc['type'])
			{
				case Common::ONE_TO_MANY:
					$this->saveOneToManyReferences($this->{$referenceAttributeName}, $assoc, $ownerId);
					break;
				case Common::MANY_TO_MANY:
					$this->saveManyToManyReferences($this->{$referenceAttributeName}, $assoc, $ownerId);
					break;
			}
		}
	}

	return $ownerId;
}