1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
RecentConfigManager.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Recent\Config;
4
5use Bitrix\Im\V2\Chat;
6use Bitrix\Im\V2\Chat\ExternalChat\ExternalTypeRegistry;
7use Bitrix\Im\V2\Chat\ExtendedType;
8use Bitrix\Main\Engine\Response\Converter;
9
11{
13
14 private static self $instance;
15
16 private array $configByTypes = [];
17 private bool $isLoaded = false;
18 private ExternalTypeRegistry $externalTypeRegistry;
19 private Converter $converterToCamelCase;
20
21 private function __construct()
22 {
23 $this->externalTypeRegistry = ExternalTypeRegistry::getInstance();
24 $this->converterToCamelCase = new Converter(Converter::TO_CAMEL | Converter::LC_FIRST);
25 }
26
27 public static function getInstance(): self
28 {
29 self::$instance ??= new self();
30
31 return self::$instance;
32 }
33
34 public function getByExtendedType(string $type): RecentConfig
35 {
36 if (!$this->isLoaded)
37 {
38 $this->load();
39 }
40
41 return $this->configByTypes[$type] ?? new RecentConfig();
42 }
43
44 public function getRecentSectionsByChat(Chat $chat): array
45 {
46 return $this->getRecentSectionsByChatExtendedType($chat->getExtendedType(false));
47 }
48
50 {
51 $config = $this->getByExtendedType($type);
52 $recentSections = [];
53
54 if ($config->useDefaultRecentSection)
55 {
56 $recentSections[] = 'default';
57 }
58
59 if ($config->hasOwnRecentSection)
60 {
61 $recentSections[] = $config->getOwnSectionName() ?? $this->converterToCamelCase->process($type);
62 }
63
64 return $recentSections;
65 }
66
67 private function load(): void
68 {
69 $this->isLoaded = true;
70 $this->loadInternal();
71 $this->loadExternal();
72 }
73
74 private function loadInternal(): void
75 {
76 $this->configByTypes[ExtendedType::Copilot->value] = new RecentConfig(true, true);
77 $this->configByTypes[ExtendedType::AiAssistant->value] = new RecentConfig(true, true);
78 $this->configByTypes[ExtendedType::AiAssistantEntity->value] = new RecentConfig(false, false);
79 $this->configByTypes[ExtendedType::Collab->value] = new RecentConfig(true, true);
80 $this->configByTypes[ExtendedType::Lines->value] = new RecentConfig(false, true);
81 $this->configByTypes[ExtendedType::Comment->value] = new RecentConfig(false, false);
82 $this->configByTypes[ExtendedType::OpenChannel->value] = new RecentConfig(true, true);
83 $this->configByTypes[ExtendedType::GeneralChannel->value]
84 = (new RecentConfig(true, true))->setOwnSectionName('openChannel')
85 ;
86 }
87
88 private function loadExternal(): void
89 {
90 $configs = $this->externalTypeRegistry->getConfigs();
91
92 foreach ($configs as $type => $config)
93 {
94 if (isset($this->configByTypes[$type]))
95 {
96 continue;
97 }
98
99 $this->configByTypes[$type] = new RecentConfig(
100 self::EXTERNAL_CHAT_USE_DEFAULT_RECENT_SECTION,
101 $config->hasOwnRecentSection
102 );
103 }
104 }
105}
$type
Определения options.php:106
getRecentSectionsByChatExtendedType(string $type)
Определения RecentConfigManager.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$config
Определения quickway.php:69