1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
filesave.php
См. документацию.
1<?php
2namespace Bitrix\Clouds;
3
4use Bitrix\Main\Localization\Loc;
5use Bitrix\Main\ORM\Data\DataManager;
6use Bitrix\Main\ORM\Fields;
7
25
27{
28 private static $files = [];
29
35 public static function getTableName()
36 {
37 return 'b_clouds_file_save';
38 }
39
45 public static function getMap()
46 {
47 return [
49 'ID',
50 [
51 'primary' => true,
52 'autocomplete' => true,
53 'title' => Loc::getMessage('FILE_SAVE_ENTITY_ID_FIELD'),
54 ]
55 ),
57 'TIMESTAMP_X',
58 [
59 'required' => true,
60 'title' => Loc::getMessage('FILE_SAVE_ENTITY_TIMESTAMP_X_FIELD'),
61 ]
62 ),
64 'BUCKET_ID',
65 [
66 'required' => true,
67 'title' => Loc::getMessage('FILE_SAVE_ENTITY_BUCKET_ID_FIELD'),
68 ]
69 ),
71 'SUBDIR',
72 [
73 'validation' => [__CLASS__, 'validateSubdir'],
74 'title' => Loc::getMessage('FILE_SAVE_ENTITY_SUBDIR_FIELD'),
75 ]
76 ),
78 'FILE_NAME',
79 [
80 'required' => true,
81 'validation' => [__CLASS__, 'validateFileName'],
82 'title' => Loc::getMessage('FILE_SAVE_ENTITY_FILE_NAME_FIELD'),
83 ]
84 ),
86 'EXTERNAL_ID',
87 [
88 'validation' => [__CLASS__, 'validateExternalId'],
89 'title' => Loc::getMessage('FILE_SAVE_ENTITY_EXTERNAL_ID_FIELD'),
90 ]
91 ),
93 'FILE_SIZE',
94 [
95 'title' => Loc::getMessage('FILE_SAVE_ENTITY_FILE_SIZE_FIELD'),
96 'size' => 8,
97 ]
98 ),
100 'BUCKET',
101 '\Bitrix\Clouds\CloudsFileBucket',
102 ['=this.BUCKET_ID' => 'ref.ID'],
103 ['join_type' => 'LEFT']
104 ),
105 ];
106 }
107
113 public static function validateSubdir(): array
114 {
115 return [
117 ];
118 }
119
125 public static function validateFileName(): array
126 {
127 return [
129 ];
130 }
131
137 public static function validateExternalId(): array
138 {
139 return [
141 ];
142 }
143
154 public static function startFileOperation($bucketId, $subDir, $fileName, $externalId)
155 {
156 $key = $bucketId . '|' . $subDir . '|' . $fileName;
157 $entity = static::getEntity();
158 $connection = $entity->getConnection();
159 if ($connection->isTableExists($entity->getDBTableName()))
160 {
162 $fileSave->setTimestampX(new \Bitrix\Main\Type\DateTime());
163 $fileSave->setBucketId($bucketId);
164 $fileSave->setSubdir($subDir);
165 $fileSave->setFileName($fileName);
166 $fileSave->setExternalId($externalId);
167 $fileSave->setFileSize(-1);
168 $saveResult = $fileSave->save();
169 if ($saveResult->isSuccess())
170 {
171 self::$files[$key] = $fileSave;
172 }
173 }
174 }
175
186 public static function setFileSize($bucketId, $subDir, $fileName, $fileSize)
187 {
188 $key = $bucketId . '|' . $subDir . '|' . $fileName;
189 if (isset(self::$files[$key]))
190 {
191 $fileSave = self::$files[$key];
192 $fileSave->setFileSize($fileSize);
193 $fileSave->save();
194 }
195 }
196
206 public static function endFileOperation($bucketId, $subDir, $fileName)
207 {
208 $key = $bucketId . '|' . $subDir . '|' . $fileName;
209 if (isset(self::$files[$key]))
210 {
211 $fileSave = self::$files[$key];
212 $fileSave->delete();
213 unset(self::$files[$key]);
214 }
215 }
216}
$connection
Определения actionsdefinitions.php:38
static endFileOperation($bucketId, $subDir, $fileName)
Определения filesave.php:206
static getMap()
Определения filesave.php:45
static setFileSize($bucketId, $subDir, $fileName, $fileSize)
Определения filesave.php:186
static validateExternalId()
Определения filesave.php:137
static validateFileName()
Определения filesave.php:125
static startFileOperation($bucketId, $subDir, $fileName, $externalId)
Определения filesave.php:154
static validateSubdir()
Определения filesave.php:113
static getTableName()
Определения filesave.php:35
static createObject($setDefaultValues=true)
Определения datamanager.php:232
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения collection.php:2
$fileName
Определения quickway.php:305
if(empty($signedUserToken)) $key
Определения quickway.php:257