• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Entity/User/User.php
  • Класс: BitrixImV2EntityUserUser
  • Вызов: User::toRestFormat
public function toRestFormat(array $option = []): array
{
	if (isset($option['USER_SHORT_FORMAT']) && $option['USER_SHORT_FORMAT'] === true)
	{
		return [
			'id' => $this->getId(),
			'name' => $this->getName(),
			'avatar' => $this->getAvatar(),
		];
	}

	$status = false;
	$idle = false;
	$lastActivityDate = false;
	$mobileLastDate = false;
	$desktopLastDate = false;

	if (!isset($option['WITHOUT_ONLINE']) || $option['WITHOUT_ONLINE'] === false)
	{
		$status = $this->getStatus();
		$idle = $this->getIdle() ? $this->getIdle()->format('c') : false;
		$lastActivityDate = $this->getLastActivityDate() ? $this->getLastActivityDate()->format('c') : false;
		$mobileLastDate = $this->getMobileLastDate() ? $this->getMobileLastDate()->format('c') : false;
		$desktopLastDate = $this->getDesktopLastDate() ? $this->getDesktopLastDate()->format('c') : false;
	}

	return [
		'id' => $this->getId(),
		'active' => $this->isActive(),
		'name' => $this->getName(),
		'firstName' => $this->getFirstName(),
		'lastName' => $this->getLastName(),
		'workPosition' => $this->getWorkPosition(),
		'color' => $this->getColor(),
		'avatar' => $this->getAvatar(),
		'avatarHr' => $this->getAvatarHr(),
		'gender' => $this->getGender(),
		'birthday' => (string)$this->getBirthday(),
		'extranet' => $this->isExtranet(),
		'network' => $this->isNetwork(),
		'bot' => $this->isBot(),
		'connector' => $this->isConnector(),
		'externalAuthId' => $this->getExternalAuthId(),
		'status' => $status,
		'idle' => $idle,
		'lastActivityDate' => $lastActivityDate,
		'mobileLastDate' => $mobileLastDate,
		'desktopLastDate' => $desktopLastDate,
		'absent' => $this->getAbsent() !== null ? $this->getAbsent()->format('c') : false,
		'departments' => $this->getDepartmentIds(),
		'phones' => empty($this->getPhones()) ? false : $this->getPhones(),
		'botData' => null,
	];
}