• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/orm/entity.php
  • Класс: BitrixMainORMEntity
  • Вызов: Entity::onUserTypeChange
static function onUserTypeChange($userfield, $id = null)
{
	// resolve UF ENTITY_ID
	if (!empty($userfield['ENTITY_ID']))
	{
		$ufEntityId = $userfield['ENTITY_ID'];
	}
	elseif (!empty($id))
	{
		$usertype = new CUserTypeEntity();
		$userfield =  $usertype->GetList([], ["ID" => $id])->Fetch();

		if ($userfield)
		{
			$ufEntityId = $userfield['ENTITY_ID'];
		}
	}

	if (empty($ufEntityId))
	{
		throw new MainArgumentException('Invalid ENTITY_ID');
	}

	// find orm entity with uf ENTITY_ID
	if (!empty(static::$ufIdIndex[$ufEntityId]))
	{
		if (!empty(static::$instances[static::$ufIdIndex[$ufEntityId]]))
		{
			// clear for further reinitialization
			static::destroy(static::$instances[static::$ufIdIndex[$ufEntityId]]);
		}
	}
}