• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/orm/objectify/entityobject.php
  • Класс: BitrixMainORMObjectifyEntityObject
  • Вызов: EntityObject::sysFillRelationCollection
public function sysFillRelationCollection($field)
{
	if ($field instanceof Relation)
	{
		$fieldName = $field->getName();
	}
	else
	{
		$fieldName = $field;
		$field = $this->entity->getField($fieldName);
	}

	/** @var Collection $collection initialize collection */
	$collection = $this->sysGetValue($fieldName);

	if (empty($collection))
	{
		$collection = $field->getRefEntity()->createCollection();
		$this->_actualValues[$fieldName] = $collection;
	}

	if (!$collection->sysIsFilled())
	{
		// we need only primary here
		$remotePrimaryDefinitions = [];

		foreach ($field->getRefEntity()->getPrimaryArray() as $primaryName)
		{
			$remotePrimaryDefinitions[] = $fieldName.'.'.$primaryName;
		}

		$this->fill($remotePrimaryDefinitions);

		// we can set fullness flag here
		$collection->sysSetFilled();
	}

	return $collection;
}