1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
MessageEvent.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Analytics\Event;
4
5use Bitrix\Disk\TypeFile;
6use Bitrix\Im\V2\Entity\File\FileCollection;
7use Bitrix\Main\Loader;
8
10{
11 protected const MULTI_TYPE = 'any';
12 protected const MEDIA_TYPE = 'media';
13 protected const UNKNOWN_TYPE = 'unknown';
14
15 public function setFilesType(FileCollection $files): self
16 {
17 if (!Loader::includeModule('disk'))
18 {
19 return $this;
20 }
21
22 $fileMap = [];
23 foreach ($files as $file)
24 {
25 $typeId = $file->getDiskFile()?->getTypeFile() ?? 0;
26 $fileMap[(int)$typeId] = (int)$typeId;
27 }
28
29 $typeCount = count($fileMap);
30
31 if (
32 $typeCount === 2
33 && isset($fileMap[TypeFile::IMAGE])
34 && isset($fileMap[TypeFile::VIDEO])
35 )
36 {
37 $this->type = self::MEDIA_TYPE;
38
39 return $this;
40 }
41
42 if ($typeCount > 1)
43 {
44 $this->type = self::MULTI_TYPE;
45
46 return $this;
47 }
48
49 $diskFileType = array_shift($fileMap);
50
51 $this->type = $this->getFileType($diskFileType) ?? self::UNKNOWN_TYPE;
52
53 return $this;
54 }
55
56 public function setFileP3(int $count): self
57 {
58 $this->p3 = 'filesCount_' . $count;
59
60 return $this;
61 }
62
63 private function getFileType(string $diskFileType): ?string
64 {
65 if (!Loader::includeModule('disk'))
66 {
67 return self::UNKNOWN_TYPE;
68 }
69
70 $diskTypeToAnalyticTypeMap = [
71 TypeFile::IMAGE => 'image',
72 TypeFile::VIDEO => 'video',
73 TypeFile::DOCUMENT => 'document',
74 TypeFile::ARCHIVE => 'archive',
75 TypeFile::SCRIPT => 'script',
76 TypeFile::UNKNOWN => 'unknown',
77 TypeFile::PDF => 'pdf',
78 TypeFile::AUDIO => 'audio',
79 TypeFile::KNOWN => 'known',
80 TypeFile::VECTOR_IMAGE => 'vector-image',
81 ];
82
83 return $diskTypeToAnalyticTypeMap[$diskFileType] ?? null;
84 }
85}
$count
Определения admin_tab.php:4
setFilesType(FileCollection $files)
Определения MessageEvent.php:15
$files
Определения mysql_to_pgsql.php:30
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936