3namespace Bitrix\Vote\Service;
5use Bitrix\Main\ArgumentTypeException;
6use Bitrix\Main\Config\Option;
7use Bitrix\Main\Context;
8use Bitrix\Main\ObjectNotFoundException;
9use Bitrix\Main\Security\Sign\BadSignatureException;
10use Bitrix\Main\Web\Uri;
11use Bitrix\Vote\Attach;
12use Bitrix\Vote\AttachTable;
16 private const SIGN_SEPARATOR =
'.';
27 $id =
$uid ?? $signedAttachId;
29 return "/vote-result/$id";
42 return str_contains($id, self::SIGN_SEPARATOR) ? $this->getAttachBySignedId($id) : $this->getAttachByUID($id);
52 private function getAttachBySignedId(
string $signedId):
Attach
54 $attachId = $this->signer->unsign($signedId);
56 return new Attach($attachId);
65 private function getAttachByUID(
string $uid):
Attach
70 return new Attach($attachId);
73 throw new ObjectNotFoundException();
78 $host = $this->getHost();
84 $request = Context::getCurrent()?->getRequest();
86 $port = (int)
$request?->getServerPort();
88 $portSuffix = $port && !in_array($port, [443, 80],
true) ?
":$port" :
'';
92 return rtrim($parsedUri->getLocator(),
'/');
95 private function getHost(): ?string
97 $fromRequest = Context::getCurrent()?->getRequest()?->getHttpHost();
103 if (defined(
'BX24_HOST_NAME') && BX24_HOST_NAME)
105 return BX24_HOST_NAME;
108 if (defined(
'SITE_SERVER_NAME') && SITE_SERVER_NAME)
110 return SITE_SERVER_NAME;
113 return Option::get(
'main',
'server_name',
null);
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
static getIdByUid(string $uid)
getAbsoluteResultUrl(string $signedAttachId, ?string $uid=null)
getAttachByUrlId(string $id)
getResultUrl(string $signedAttachId, ?string $uid)