• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/orm/query/query.php
  • Класс: Bitrix\Main\ORM\Query\Query
  • Вызов: Query::registerChain
public function registerChain($section, Chain $chain, $opt_key = null)
{
	$alias = $chain->getAlias();

	if (isset($this->global_chains[$alias]))
	{
		if ($this->global_chains[$alias]->getDefinition() == $chain->getDefinition())
		{
			$reg_chain = $this->global_chains[$alias];
		}
		else
		{
			// we have a collision
			// like book.author_id and book.author.id have the same aliases, but different definitions
			// in most of the cases it's not a problem, there would be the same expected data
			// but we need register this chain separately to be available for internal usage
			$reg_chain = $chain;

			$this->global_chains[$reg_chain->getDefinition()] = $chain;

			// or should we make unique alias and register with it?
			$alias = $this->getUniqueAlias();
			$chain->setCustomAlias($alias);
			$this->global_chains[$alias] = $chain;
		}
	}
	else
	{
		$reg_chain = $chain;
		$def = $reg_chain->getDefinition();

		$this->global_chains[$alias] = $chain;
		$this->global_chains[$def] = $chain;
	}

	$storage_name = $section . '_chains';

	// in case of collision do not rewrite by alias
	if (!isset($this->{$storage_name}[$alias]))
	{
		$this->{$storage_name}[$alias] = $reg_chain;
		// should we store by definition too?
	}

	if (!is_null($opt_key))
	{
		$this->{$storage_name}[$opt_key] = $reg_chain;
	}

	return $reg_chain;
}