5use Bitrix\Disk\TypeFile;
7use Bitrix\Im\Model\EO_LinkFile;
8use Bitrix\Im\V2\Common\MigrationStatusCheckerTrait;
19 use MigrationStatusCheckerTrait;
32 self::DOCUMENT_SUBTYPE,
47 $this->initByDefault();
57 if (!static::isMigrationFinished())
62 return parent::save();
67 if (static::isSubtypeValid($this->
getSubtype()))
77 return in_array($subtype, static::ALLOWED_SUBTYPE,
true);
82 return mb_strtoupper($subtypeInJsonFormat);
87 return Entity\File\FileItem::class;
97 $this->subtype = $subtype;
105 return $this->subtype;
112 if (!isset($this->entity))
114 return self::OTHER_SUBTYPE;
120 if ($realFile->getCode() === static::BRIEF_CODE)
122 return static::BRIEF_SUBTYPE;
125 if ($realFile->getCode() === static::MEDIA_ORIGINAL_CODE)
127 return static::OTHER_SUBTYPE;
135 switch ($diskFileType)
137 case TypeFile::IMAGE:
138 case TypeFile::VIDEO:
139 return static::MEDIA_SUBTYPE;
141 case TypeFile::DOCUMENT:
143 return static::DOCUMENT_SUBTYPE;
145 case TypeFile::AUDIO:
146 return static::AUDIO_SUBTYPE;
149 return static::OTHER_SUBTYPE;
155 if (isset($this->entity))
160 $fileEntity = \Bitrix\Im\V2\Entity\File\FileItem::initByDiskFileId($this->
getEntityId(), $this->
getChatId());
162 if ($fileEntity !==
null)
172 return LinkFileTable::class;
177 $entity = LinkFileTable::query()
178 ->setSelect([
'ID',
'MESSAGE_ID',
'CHAT_ID',
'SUBTYPE',
'DISK_FILE_ID',
'DATE_CREATE',
'AUTHOR_ID'])
189 return (
new static(
$entity))->fillFile();
194 if (isset($this->entity))
199 return parent::setChatId(
$chatId);
209 return $this->entity;
224 return parent::setEntity($entity->setChatId($this->chatId ??
null));
234 return 'DISK_FILE_ID';
239 $additionalFields = [
241 'field' =>
'subtype',
242 'set' =>
'setSubtype',
243 'get' =>
'getSubtype',
244 'beforeSave' =>
'validateSubtype',
248 return array_merge(parent::mirrorDataEntityFields(), $additionalFields);
260 'subType' => mb_strtolower($this->
getSubtype()),
const UNKNOWN_FILE_SUBTYPE
static getRestEntityName()
static getEntityClassName()
toRestFormat(array $option=[])
static getSubtypeFromJsonFormat(string $subtypeInJsonFormat)
getPopupData(array $excludedList=[])
__construct($source=null)
static string $migrationOptionName
static isSubtypeValid(string $subtype)
setSubtype(string $subtype)
setEntity(RestEntity $entity)
const MEDIA_ORIGINAL_CODE
static getEntityIdFieldName()
static getByDiskFileId(int $diskFileId)
getSubtypeByDiskFileType(string $diskFileType)
static mirrorDataEntityFields()