• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/controller/activity/gotochat.php
  • Класс: Bitrix\Crm\Controller\Activity\GoToChat
  • Вызов: GoToChat::validateEntity
private function validateEntity(int $entityTypeId, int $entityId): Result
{
	$result = new Result();
	if (!\CCrmOwnerType::IsDefined($entityTypeId))
	{
		$result->addError(ErrorCode::getEntityTypeNotSupportedError($entityTypeId));

		return $result;
	}

	$factory = Container::getInstance()->getFactory($entityTypeId);
	if (!$factory)
	{
		$result->addError(ErrorCode::getEntityTypeNotSupportedError($entityTypeId));

		return $result;
	}

	$item = $factory->getItem($entityId);
	if($item === null)
	{
		$result->addError(ErrorCode::getNotFoundError());
	}

	if (!Container::getInstance()->getUserPermissions()->canReadItem($item))
	{
		$result->addError(ErrorCode::getAccessDeniedError());
	}

	return $result;
}