1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
uploadedfilesregistry.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\UserField\File;
4
5use Bitrix\Main\Application;
6
8{
9 private const SESSION_CODE_PREFIX = 'UploadedFilesRegistry_';
10 private static ?self $instance = null;
11
12 public static function getInstance(): self
13 {
14 self::$instance ??= new self();
15
16 return self::$instance;
17 }
18
19 public function registerFile(int $fileId, string $controlId, string $cid, string $tempFileToken): void
20 {
21 $session = Application::getInstance()->getSession();
22 if (!isset($session[self::SESSION_CODE_PREFIX . $controlId]))
23 {
24 $session[self::SESSION_CODE_PREFIX . $controlId] = [];
25 }
26
27 $session[self::SESSION_CODE_PREFIX . $controlId][$fileId] = [
28 'cid' => $cid,
29 'token' => $tempFileToken,
30 ];
31 }
32
33 public function getTokenByFileId(string $controlId, int $fileId): ?string
34 {
35 $session = Application::getInstance()->getSession();
36
37 return $session[self::SESSION_CODE_PREFIX . $controlId][$fileId]['token'] ?? null;
38 }
39
40 public function getCidByFileId(string $controlId, int $fileId): ?string
41 {
42 $session = Application::getInstance()->getSession();
43
44 return $session[self::SESSION_CODE_PREFIX . $controlId][$fileId]['cid'] ?? null;
45 }
46
47 public function unregisterFile(string $controlId, int $fileId): void
48 {
49 $session = Application::getInstance()->getSession();
50 if (isset($session[self::SESSION_CODE_PREFIX . $controlId][$fileId]))
51 {
52 unset($session[self::SESSION_CODE_PREFIX . $controlId][$fileId]);
53 }
54 if (empty($session[self::SESSION_CODE_PREFIX . $controlId]))
55 {
56 unset($session[self::SESSION_CODE_PREFIX . $controlId]);
57 }
58 }
59}
static getInstance()
Определения application.php:98
registerFile(int $fileId, string $controlId, string $cid, string $tempFileToken)
Определения uploadedfilesregistry.php:19
getTokenByFileId(string $controlId, int $fileId)
Определения uploadedfilesregistry.php:33
unregisterFile(string $controlId, int $fileId)
Определения uploadedfilesregistry.php:47
getCidByFileId(string $controlId, int $fileId)
Определения uploadedfilesregistry.php:40