Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
TempFileTable.php
1<?php
2
4
12
29class TempFileTable extends Data\DataManager
30{
31 public static function getTableName()
32 {
33 return 'b_ui_file_uploader_temp_file';
34 }
35
36 public static function getObjectClass()
37 {
38 return TempFile::class;
39 }
40
41 public static function getMap()
42 {
43 return [
44 (new Fields\IntegerField('ID'))
45 ->configurePrimary()
46 ->configureAutocomplete()
47 ,
48
49 (new Fields\StringField("GUID"))
50 ->configureUnique(true)
51 ->configureNullable(false)
52 ->configureDefaultValue(static function () {
53 return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
54 mt_rand(0, 0xffff), mt_rand(0, 0xffff),
55 mt_rand(0, 0xffff),
56 mt_rand(0, 0x0fff) | 0x4000,
57 mt_rand(0, 0x3fff) | 0x8000,
58 mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
59 );
60 })
61 ->configureSize(36)
62 ,
63
64 new Fields\IntegerField('FILE_ID'),
65
66 (new Fields\StringField('FILENAME'))
67 ->configureRequired()
68 ->configureSize(255)
69 ,
70
71 (new Fields\IntegerField('SIZE'))
72 ->configureRequired()
73 ,
74
75 (new Fields\StringField('PATH'))
76 ->configureRequired()
77 ->configureSize(255)
78 ,
79
80 (new Fields\StringField('MIMETYPE'))
81 ->configureRequired()
82 ->configureSize(255)
83 ,
84
85 new Fields\IntegerField('RECEIVED_SIZE'),
86 new Fields\IntegerField('WIDTH'),
87 new Fields\IntegerField('HEIGHT'),
88
89 new Fields\IntegerField('BUCKET_ID'),
90 (new Fields\StringField('MODULE_ID'))
91 ->configureRequired()
92 ->configureSize(50)
93 ,
94
95 (new Fields\StringField('CONTROLLER'))
96 ->configureRequired()
97 ->configureSize(255)
98 ,
99
100 (new Fields\BooleanField('CLOUD'))
101 ->configureValues(0, 1)
102 ->configureDefaultValue(0)
103 ,
104
105 (new Fields\BooleanField('UPLOADED'))
106 ->configureValues(0, 1)
107 ->configureDefaultValue(0)
108 ,
109
110 (new Fields\BooleanField('DELETED'))
111 ->configureValues(0, 1)
112 ->configureDefaultValue(0)
113 ,
114
115 (new Fields\IntegerField('CREATED_BY'))
116 ->configureRequired()
117 ->configureDefaultValue(static function () {
118 global $USER;
119 if (is_object($USER) && method_exists($USER, 'getId'))
120 {
121 return (int)$USER->getId();
122 }
123
124 return 0;
125 })
126 ,
127
128 (new Fields\DatetimeField('CREATED_AT'))
129 ->configureDefaultValue(static function () {
130 return new DateTime();
131 })
132 ,
133
134 (new Reference(
135 'FILE',
136 \Bitrix\Main\FileTable::class,
137 Join::on('this.FILE_ID', 'ref.ID'),
138 ['join_type' => Join::TYPE_INNER]
139 )),
140 ];
141 }
142
143 public static function onDelete(Event $event)
144 {
145 $tempFile = $event->getParameter('object');
146 if (!$tempFile)
147 {
148 $id = $event->getParameter('primary')['ID'];
149 $tempFile = self::getById($id)->fetchObject();
150 }
151
152 if ($tempFile)
153 {
154 $tempFile->fill();
155
156 $deleteBFile = $tempFile->customData->get('deleteBFile') !== false;
157 $tempFile->deleteContent($deleteBFile);
158 }
159 }
160}
getParameter($key)
Definition event.php:80