1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Application.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2;
4
5use Bitrix\Im\V2\Application\Config;
6use Bitrix\Main\Web\Json;
7
9{
10 public const MESSENGER_APP_NAME = 'messenger';
11 public const QUICK_ACCESS_APP_NAME = 'quickAccess';
12
13 private Config $config;
14
15 public function __construct(?Config $config = null)
16 {
17 $this->config = $config ?? new Config();
18 }
19
20 public function getTemplate(string $appName): string
21 {
22 $preparedConfig = Json::encode($this->config);
23 $then = $this->getThen($appName);
24
25 return "
26 BX.ready(function() {
27 BX.Messenger.v2.Application.Launch('{$appName}', {$preparedConfig})
28 .then((application) => {
29 {$then}
30 });
31 });
32 ";
33 }
34
35 public function getConfig(): Config
36 {
37 return $this->config;
38 }
39
40 public function isAirDesignEnabled(): bool
41 {
42 return (
43 \Bitrix\Main\Loader::includeModule('intranet')
44 && class_exists(\Bitrix\Intranet\Integration\Templates\Air\AirTemplate::class)
45 && method_exists(\Bitrix\Intranet\Integration\Templates\Air\AirTemplate::class, 'isEnabled')
46 && \Bitrix\Intranet\Integration\Templates\Air\AirTemplate::isEnabled()
47 );
48 }
49
50 public function shouldHideQuickAccess(): bool
51 {
52 return defined('BX_IM_FULLSCREEN') && BX_IM_FULLSCREEN;
53 }
54
55 protected function getThen(string $appName): string
56 {
57 return $appName === self::MESSENGER_APP_NAME ? "application.initComponent('body')" : '';
58 }
59}
shouldHideQuickAccess()
Определения Application.php:50
const QUICK_ACCESS_APP_NAME
Определения Application.php:11
getThen(string $appName)
Определения Application.php:55
const MESSENGER_APP_NAME
Определения Application.php:10
isAirDesignEnabled()
Определения Application.php:40
getTemplate(string $appName)
Определения Application.php:20
__construct(?Config $config=null)
Определения Application.php:15
$config
Определения quickway.php:69