• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/orm/query/result.php
  • Класс: BitrixMainORMQueryResult
  • Вызов: Result::composeRemoteObject
protected function composeRemoteObject($entity, $primaryValues, $objectValues)
{
	// if null primary then return null
	if (current($primaryValues) === null)
	{
		return null;
	}

	// try to get remote object from identity map
	/** @var $remoteObject EntityObject */
	$objectClass = $entity->getObjectClass();
	$remoteObject = $this->identityMap->get($objectClass, $primaryValues);

	// do we have a new object to add to identity map
	$addToIM = false;

	if (empty($remoteObject))
	{
		// define new object
		$remoteObject = new $objectClass(false);

		// set right state
		$remoteObject->sysChangeState(State::ACTUAL);

		// add to identityMap later, when primary is set
		$addToIM = true;
	}

	// set all values of remote object
	foreach ($objectValues as $fieldName => $objectValue)
	{
		/** @var ScalarField $field */
		$field = $entity->getField($fieldName);
		$castValue = $field->cast($objectValue);

		$remoteObject->sysSetActual($fieldName, $castValue);
	}

	// save to identityMap
	if ($addToIM)
	{
		$this->identityMap->put($remoteObject);
	}

	return $remoteObject;
}