• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/internals/notification/userrepository.php
  • Класс: BitrixTasksInternalsNotificationUserRepository
  • Вызов: UserRepository::getUserById
public function getUserById(int $userId): ?User
{
	if (isset($this->cache[$userId]))
	{
		return $this->cache[$userId];
	}

	$res = UserTable::query()
		->where('ID', $userId)
		->setSelect([
			'ID',
			'NAME',
			'LAST_NAME',
			'SECOND_NAME',
			'EMAIL',
			'EXTERNAL_AUTH_ID',
			'PERSONAL_GENDER',
			'NOTIFICATION_LANGUAGE_ID'
		])
		->exec()
		->fetchObject()
	;

	if (!$res)
	{
		return null;
	}

	$user = new User(
		$res->getId(),
		$res->getName(),
		$res->getNotificationLanguageId(),
		[
			'gender' => $res->getPersonalGender(),
			'last_name' => $res->getLastName(),
			'second_name' => $res->getSecondName(),
			'email' => $res->getEmail(),
			'external_auth_id' => $res->getExternalAuthId(),
		]
	);

	$this->cache[$user->getId()] = $user;

	return $user;
}